Skip to content

Add switch "MoveTreeViewTextLocationOnePixel" for update the drawing position of the Treeview node #44403

@LeafShi1

Description

@LeafShi1

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


Associated WorkItem - 367790

Metadata

Metadata

Assignees

Labels

🏁 Release: .NET 10Work items for the .NET 10 release📌 seQUESTeredIdentifies that an issue has been imported into Quest.breaking-changeIndicates a .NET Core breaking changein-prThis issue will be closed (fixed) by an active pull request.

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions