Skip to content

Fix The nodes of TreeView not in dark mode when editing it#14787

Open
Sathish-087 wants to merge 3 commits into
dotnet:mainfrom
Sathish-087:Fix_Issue_12042
Open

Fix The nodes of TreeView not in dark mode when editing it#14787
Sathish-087 wants to merge 3 commits into
dotnet:mainfrom
Sathish-087:Fix_Issue_12042

Conversation

@Sathish-087

@Sathish-087 Sathish-087 commented Jul 20, 2026

Copy link
Copy Markdown

Fixes #12042

Proposed changes

  • Handle WM_CTLCOLOREDIT in TreeView.WndProc for the native in-place node label edit control.
  • Handle WM_CTLCOLOREDIT in ListView.WndProc for the native in-place item label edit control to maintain consistent dark-mode behavior.
  • Use the existing InitializeDCForWmCtlColor infrastructure to apply the correct foreground and background colors to the native edit control during label editing.

Customer Impact

  • TreeView node text editing now correctly respects dark mode colors instead of displaying a light-themed edit box.
  • ListView item label editing receives the same color handling, ensuring a consistent experience across editable controls.
  • Improves visual consistency and usability when editing labels in dark-themed WinForms applications.

Regression?

  • No

Risk

  • Low. The change only affects the WM_CTLCOLOREDIT path for native label-edit controls and reuses the existing InitializeDCForWmCtlColor implementation already used throughout WinForms color initialization logic.

Screenshots

Before

TreeViewEditIssue.mp4

After

TreeViewEditFixDemo.mp4

Test methodology

  • Verified that TVN_BEGINLABELEDITW creates a native edit control and that WM_CTLCOLOREDIT is raised by the edit control during painting.
  • Confirmed that routing WM_CTLCOLOREDIT to InitializeDCForWmCtlColor correctly applies the control's ForeColor and BackColor.
  • Tested label editing in both TreeView and ListView under dark mode and verified that text and background colors match the parent control.

Accessibility testing

  • No accessibility regressions observed. The change only updates color initialization for the native label-edit control and does not modify accessibility properties, keyboard navigation, or UI Automation behavior.

Test environment(s)

  • Windows 11
  • .NET SDK: 11.0.100-preview.5.26302.115
Microsoft Reviewers: Open in CodeFlow

@Sathish-087
Sathish-087 requested a review from a team as a code owner July 20, 2026 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Dark Mode] The nodes of TreeView not in dark mode when editing it

1 participant