Skip to content

Fix ComboBox drop-down button incorrectly uses BackColor - #14861

Open
LeafShi1 wants to merge 2 commits into
dotnet:mainfrom
LeafShi1:Fix_14849_ComboBox_drop-down_button_incorrectly_uses_BackColor
Open

Fix ComboBox drop-down button incorrectly uses BackColor#14861
LeafShi1 wants to merge 2 commits into
dotnet:mainfrom
LeafShi1:Fix_14849_ComboBox_drop-down_button_incorrectly_uses_BackColor

Conversation

@LeafShi1

@LeafShi1 LeafShi1 commented Aug 6, 2026

Copy link
Copy Markdown
Member

Fixes #14849

Root Cause

The NET11 ModernComboAdapter treated ComboBox.BackColor as the base color for the drop-down button. As a result, assigning a custom field background also tinted the button, unlike Classic mode where the button remains system-rendered.

Proposed changes

  • Update the NET11 ComboBox renderer so the drop-down button no longer derives its surface color from ComboBox.BackColor.

Customer Impact

  • Setting BackColor customizes only the editable field, the drop-down button retains a neutral system appearance.

Regression?

  • No

Risk

  • Minimal

Screenshots

Before

Editable field and drop-down button both use/tint from BackColor.

Image

After

Only the editable field uses BackColor, the drop-down button retains neutral system chrome.

DarkMode:
image

Light mode:
image

Test methodology

  • Manually

Test environment(s)

  • .net 11.0.0-rc.1.26405.103
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

Adjusts the NET11 modern ComboBox renderer so the drop-down button no longer picks up the control’s BackColor, aligning the visual behavior more closely with Classic mode expectations (custom field background without tinting the button chrome).

Changes:

  • Switch drop-down button rendering to use a fixed “base” surface color instead of GetEffectiveBackColor(comboBox).
  • Add a helper (GetDropDownButtonBaseColor) that selects a system-derived base color (with a dark-mode variant).
Suppressed comments (1)

src/System.Windows.Forms/System/Windows/Forms/Controls/ComboBox/ComboBox.ModernComboAdapter.cs:208

  • This change alters rendering behavior (drop-down button background no longer derives from ComboBox.BackColor), but there doesn’t appear to be a regression test asserting the button region ignores a custom BackColor under VisualStylesMode.Net11. There are already bitmap-based tests in ComboBoxTests.cs for modern adapter rendering, so adding a similar test (sampling pixels within _buttonBounds) would help prevent regressions of #14849.
            Color background = GetDropDownButtonBaseColor(comboBox);
            Color buttonColor = comboBox._mousePressed
                ? PopupButtonColorMath.Blend(
                    background,
                    Application.SystemVisualSettings.AccentColor,

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

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@SimonZhao888

Copy link
Copy Markdown
Member

Looks good to me!

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.

ComboBox drop-down button incorrectly uses BackColor under VisualStylesMode.NET11

3 participants