-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Description
Description
The TreeNode in the TreeView control allows users to customize DrawMode and add checkboxes. However, under certain conditions (CheckBoxes=true,DrawMode=OwnerDrawText, In OnDrawNode event set DrawDefault=true), the checkbox image will be truncated due to the position of the TreeNode text drawing. To avoid affecting normal common use, an AppContext switch setting is added here to solve the problem of checkbox truncation in certain situations.
Version
.NET 10 Preview 1
Previous behavior
TreeView control with CheckBoxes=true, DrawMode=OwnerDrawText, and set DrawDefault=true in OnDrawNode event
the TreeNode CheckBox images are shown truncated on the right border.
New behavior
Set switch "System.Windows.Forms.TreeView.MoveTreeViewTextLocationOnePixel": true in project's runtime config file and then when TreeView with CheckBoxes=true, DrawMode=OwnerDrawText, and set DrawDefault=true in OnDrawNode event, the TreeNode'checkboxes can be shown completed
Type of breaking change
- Binary incompatible: Existing binaries might encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
- Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code might require source changes to compile successfully.
- Behavioral change: Existing binaries might behave differently at run time.
Reason for change
This change ensures that the checkbox of the node in the TreeView control can be fully displayed.
Recommended action
Users need to manually add "System.Windows.Forms.TreeView.MoveTreeViewTextLocationOnePixel": true to their project's runtimeconfig.json file to turn on the switch.
Feature area
Windows Forms
Affected APIs
https://learn.microsoft.com/dotnet/api/system.windows.forms.treeview.checkboxes