-
Notifications
You must be signed in to change notification settings - Fork 997
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recalculate the node position of the TreeView when DrawMode = TreeViewDrawMode.OwnerDrawText #12698
base: main
Are you sure you want to change the base?
Recalculate the node position of the TreeView when DrawMode = TreeViewDrawMode.OwnerDrawText #12698
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #12698 +/- ##
===================================================
- Coverage 76.13468% 76.13409% -0.00060%
===================================================
Files 3242 3242
Lines 642363 642410 +47
Branches 47271 47279 +8
===================================================
+ Hits 489061 489093 +32
- Misses 149751 149776 +25
+ Partials 3551 3541 -10
Flags with carried forward coverage won't be shown. Click here to find out more. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had you tested this change at different scaling factors and in different level nodes in a tree view? For example 3rd level child?
It will be helpful to add code comments that describe what the constants are for.
src/System.Windows.Forms/src/System/Windows/Forms/Controls/TreeView/TreeView.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/Controls/TreeView/TreeView.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/Controls/TreeView/TreeView.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/Controls/TreeView/TreeView.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/Controls/TreeView/TreeView.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (3)
src/System.Windows.Forms/src/System/Windows/Forms/Controls/TreeView/TreeView.cs:2907
- [nitpick] The method name 'PreferredHeight' is not very descriptive. Consider renaming it to 'CalculatePreferredHeight'.
private int PreferredHeight
src/System.Windows.Forms/src/System/Windows/Forms/Controls/TreeView/TreeView.cs:2921
- [nitpick] The method name 'GetNodeHeight' is not very descriptive. Consider renaming it to 'CalculateNodeHeight'.
private int GetNodeHeight(TreeNode node)
src/System.Windows.Forms/src/System/Windows/Forms/Controls/TreeView/TreeView.cs:2741
- Using 'goto' is generally considered bad practice. Consider refactoring the code to eliminate the need for 'goto'.
goto default;
13f6c73
to
3841b91
Compare
…wDrawMode.OwnerDrawText
8ecf0b8
to
c5f0f04
Compare
No regressions found in private PRs |
Fixes #12681
Root Cause
When
treeView.DrawMode = TreeViewDrawMode.OwnerDrawText
, the node'sFillRectangle
andFocusRectangle
positions are calculated incorrectlyProposed changes
CustomDraw
of the TreeView.cs, WhenRightToLeft == RightToLeft.Yes && RightToLeftLayout
reverses the X drawing coordinates ofFillRectangle
andFocusRectangle
Customer Impact
Regression?
Risk
Screenshots
Before
After
When setting RightToLeft = Yes, RightToLeftLayout = True and .DrawMode = TreeViewDrawMode.OwnerDrawText, the selected node box is fully rendered
Test methodology
Test environment(s)
Microsoft Reviewers: Open in CodeFlow