Skip to content

Fix editable control border color in NET11 visual styles - #14853

Draft
LeafShi1 wants to merge 1 commit into
dotnet:mainfrom
LeafShi1:Fix_control_color_issue_under_VisualStylesMode.NET11
Draft

Fix editable control border color in NET11 visual styles#14853
LeafShi1 wants to merge 1 commit into
dotnet:mainfrom
LeafShi1:Fix_control_color_issue_under_VisualStylesMode.NET11

Conversation

@LeafShi1

@LeafShi1 LeafShi1 commented Aug 5, 2026

Copy link
Copy Markdown
Member

Fixes #14847

Proposed changes

Introduce shared editable-control border color logic in ModernControlColorMath and use it across NET11 editable renderers.

  • Uses a stable border color instead of ForeColor.
  • Applies the shared border color to TextBoxBase, ComboBox.ModernComboAdapter, and UpDownBase.
  • Uses a visible dark-mode border color.

Customer Impact

  • Customers using VisualStylesMode.Net11 can customize editable-control text colors without unintentionally changing the control border.

Regression?

  • No

Risk

  • Minimal

Screenshots

Before

Changing ForeColor on editable controls in VisualStylesMode.Net11 also change the border color.

Image

After

Editable-control border color is independent from ForeColor.

LightMode DarkMode

Test methodology

  • Manually

Test environment(s)

  • .net11.0.0-rc.1.26404.101
Microsoft Reviewers: Open in CodeFlow

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a VisualStylesMode.Net11 rendering issue where changing ForeColor on editable controls unintentionally changes the control border color. It centralizes “editable text control” border-color selection in ModernControlColorMath and updates the NET11 renderers for TextBoxBase, ComboBox, and UpDownBase to use this shared logic (including a dark-mode-specific border color).

Changes:

  • Added shared editable-control border color selection and enabled/disabled handling in ModernControlColorMath.
  • Updated TextBoxBase and UpDownBase modern border rendering to use the shared border color instead of ForeColor.
  • Updated ComboBox.ModernComboAdapter border rendering to use the shared border color (and simplified border-color selection logic).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/System.Windows.Forms/System/Windows/Forms/Rendering/ModernControlColorMath.cs Introduces shared border color defaults and an enabled/disabled border color helper.
src/System.Windows.Forms/System/Windows/Forms/Controls/UpDown/UpDownBase.cs Uses shared border color logic for NET11 modern border rendering instead of ForeColor.
src/System.Windows.Forms/System/Windows/Forms/Controls/TextBox/TextBoxBase.cs Uses shared border color logic for NET11 non-client painting instead of ForeColor.
src/System.Windows.Forms/System/Windows/Forms/Controls/ComboBox/ComboBox.ModernComboAdapter.cs Switches modern ComboBox border rendering to shared border color logic and simplifies the helper signature.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +20 to +23
internal static Color TextControlBorderColor
=> Application.IsDarkModeEnabled
? s_darkModeTextControlBorder
: SystemColors.ControlDarkDark;
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.

ForeColor incorrectly affects the border color of editable controls under VisualStylesMode.NET11

2 participants