Fixed the issue where text in controls such as TextBox and ComboBox was obscured at the bottom. - #14887
Fixed the issue where text in controls such as TextBox and ComboBox was obscured at the bottom.#14887SimonZhao888 wants to merge 24 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refines single-line TextBox layout under VisualStylesMode.Net11 by reducing excess vertical whitespace and stabilizing the text-to-border geometry while keeping classic compatibility expectations.
Changes:
- Align modern
PreferredHeightbehavior with the classic (Everett) preferred-height formula. - Add single-line client-area carve adjustments during
WM_NCCALCSIZEto prevent overly large vertical padding from shrinking the usable text area. - Update/add unit tests to assert the new preferred-height and non-client/client-area behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/System.Windows.Forms/System/Windows/Forms/Controls/TextBox/TextBoxBase.cs | Changes modern preferred-height selection and adjusts single-line padding carve logic in WM_NCCALCSIZE. |
| src/test/unit/System.Windows.Forms/TextBoxBaseTests.cs | Updates existing tests and adds regression tests for preferred height, padding, and border/non-client behavior in Net11 mode. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…UpDown controls under different scaling settings.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (2)
src/test/unit/System.Windows.Forms/TextBoxBaseTests.cs:226
- The minimum client-height assertion uses a hard-coded "+ 3" pixels, which can be incorrect when the test is executed under non-96 DPI. The production code scales this margin with DPI (LogicalToDeviceUnits/ScaleToDpi), so the test should scale the 3px term as well to avoid DPI-dependent failures.
Assert.True(control.ClientSize.Height >= control.Font.Height + 3);
src/test/unit/System.Windows.Forms/TextBoxBaseTests.cs:246
- This pixel-based border assertion may be flaky because the control BackColor is set to White, which can match the rendered border color in some themes/high-contrast configurations. Using an uncommon BackColor reduces the chance of accidental equality while still validating that the top/bottom border pixels are not client-filled.
BackColor = Color.White,
ForeColor = Color.Black,
Size = new Size(120, s_preferredHeight)
};
Done. |
…nner and more consistent across common DPI settings, mitigating the visual issue where rounded corners appear thicker than straight lines.
3391db9 to
f184e24
Compare
… that it is no longer the same as the height of controls in Classic mode.
…he UpDown control buttons.
…=DropDown and DropDownList.
…rect at 350% DPI, causing the first character to be cut off.
b8935dc to
ecc17db
Compare
…de, repro on all DPI values: 100%DPI ~ 300%DPI
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #14887 +/- ##
=============================================
Coverage 37.24166% 37.24166%
=============================================
Files 246 246
Lines 9774 9774
Branches 1029 1029
=============================================
Hits 3640 3640
Misses 5970 5970
Partials 164 164
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|



Fixes #14938
Root Cause
In VisualStylesMode.Net11, single-line input controls inherited excessive vertical padding and chrome metrics, making TextBox, ComboBox, and UpDown-based controls unnecessarily tall. Reducing that space exposed additional native-control layout issues:
Proposed changes
Customer Impact
Screenshots
Before
After
Scale 350%

Scale 300%

Scale 250%

Scale 225%

Scale 200%

Scale 175%

Scale 150%

Scale 125%

Scale 100%

Test methodology
Test environment(s)
Microsoft Reviewers: Open in CodeFlow