Fix issue 14795: ComboBox with DropDownStyle.Simple renders incorrectly and displays an unexpected vertical scrollbar - #14827
Open
SimonZhao888 wants to merge 4 commits into
Open
Conversation
…ly and displays an unexpected vertical scrollbar
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses WinForms issue #14795 by correcting the Net11 modern-visual-styles rendering/layout of ComboBoxStyle.Simple, eliminating the visual interference that produced an unexpected vertical scrollbar strip and improving edit/list geometry consistency.
Changes:
- Adjusts modern Simple-mode layout to stabilize edit/list sizing, remove list borders, and clip the list bottom to preserve the rounded outer frame.
- Adds an accent-colored divider between the edit area and the list area during modern painting.
- Adds regression tests covering Simple-mode edit/list bounds, divider rendering, list border removal, and CreateParams flags.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/test/unit/System.Windows.Forms/System/Windows/Forms/ComboBoxTests.cs | Adds regression tests for modern Net11 + Simple layout, divider rendering, and style flags. |
| src/System.Windows.Forms/System/Windows/Forms/Controls/ComboBox/ComboBox.ModernComboAdapter.cs | Draws an accent divider between the Simple edit and list areas during modern rendering. |
| src/System.Windows.Forms/System/Windows/Forms/Controls/ComboBox/ComboBox.Modern.cs | Reworks modern Simple-mode geometry; removes list borders; applies a clip region to avoid rounding artifacts. |
| src/System.Windows.Forms/System/Windows/Forms/Controls/ComboBox/ComboBox.cs | Tweaks CreateParams (integral height for modern Simple) and applies list border adjustments on handle creation; modernizes NCCALCSIZE/NCHITTEST behavior for Simple. |
Comments suppressed due to low confidence (2)
src/test/unit/System.Windows.Forms/System/Windows/Forms/ComboBoxTests.cs:1315
- These assertions only check one-sided bounds (<= / >=), which can let significant misalignment slip through. Using InRange with a small tolerance makes the test better at catching regressions while still allowing minor off-by-one differences.
Assert.True(listBounds.Left <= control.ModernChromeInsets.Left);
Assert.True(listBounds.Right >= control.ClientRectangle.Right - control.ModernChromeInsets.Right - 1);
src/System.Windows.Forms/System/Windows/Forms/Controls/ComboBox/ComboBox.Modern.cs:610
- The value "2" is a magic number used to crop the visible list area. Giving it a named constant (even a local const) makes it clearer what the crop represents and helps keep related calculations consistent if it needs adjustment later.
int bottomShrink = ScaleHelper.ScaleToDpi(2, DeviceDpiInternal);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
LeafShi1
reviewed
Jul 31, 2026
LeafShi1
reviewed
Jul 31, 2026
LeafShi1
reviewed
Jul 31, 2026
LeafShi1
reviewed
Jul 31, 2026
LeafShi1
reviewed
Jul 31, 2026
LeafShi1
reviewed
Jul 31, 2026
added 2 commits
August 3, 2026 10:43
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #14795
Root Cause
When
VisualStylesModeis set toNet11,ComboBoxStyle.Simpleretains certain "classic/native" geometric and non-client area behaviors, resulting in inconsistencies when overlaid with modern rendering:Proposed changes
Customer Impact
Regression?
Risk
Screenshots
Before
After
Normal
DarkMode
Test methodology
Test environment(s)
Microsoft Reviewers: Open in CodeFlow