Repository navigation
Fix UpDown control layout when changing and resetting fonts - #15374
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #15374 +/- ##
=============================================
Coverage 39.79260% 39.79260%
=============================================
Files 246 246
Lines 9836 9836
Branches 1036 1036
=============================================
Hits 3914 3914
Misses 5741 5741
Partials 181 181
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Note
Copilot was unable to run its full agentic suite in this review.
Copilot review overview
6 open issues
The newreceivesFontChangedcheck is intended to control skipping/scaling behavior for… · New This line changes howcausedByFontChangedis propagated toScale(...)based onIsFontSet().… · New WithAutoScaleFactorno longer updating_currentAutoScaleFactorin its getter,… · New WithAutoScaleFactorno longer updating_currentAutoScaleFactorin its getter,… · New WithAutoScaleFactorno longer updating_currentAutoScaleFactorin its getter,… · New WithAutoScaleFactorno longer updating_currentAutoScaleFactorin its getter,… · New
What changed in this PR
Updates WinForms font autoscaling behavior to correctly scale nested/inheriting container controls during parent font changes, while avoiding unintended scaling side-effects.
Changes:
- Add unit tests covering font changes and autoscaling interactions for
UpDownBaseandContainerControl. - Adjust
ContainerControlfont-change autoscaling to temporarily retain a scaling factor during propagation, then restore it. - Refine
Control.ScaleChildControlsto avoid double-scaling container controls that will scale viaOnParentFontChanged, while still scaling containers with explicit fonts.
| File | Description |
|---|---|
| src/test/unit/System.Windows.Forms/System/Windows/Forms/UpDownBaseTests.cs | Adds regression coverage for UpDownBase bounds/width/location behavior when parent fonts change and fonts reset. |
| src/test/unit/System.Windows.Forms/System/Windows/Forms/ContainerControlTests.cs | Adds tests validating scaling of inheriting/nested containers across parent font changes and explicit font scenarios. |
| src/System.Windows.Forms/System/Windows/Forms/Layout/Containers/ContainerControl.cs | Changes how autoscale factor is retained/restored during OnFontChanged to support correct child scaling. |
| src/System.Windows.Forms/System/Windows/Forms/Control.cs | Updates child scaling logic to skip container controls that will handle scaling themselves, and modifies how causedByFontChanged is propagated. |
Review effort: Lite
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the font-based autoscaling fix.
No open issues 🎉
6 resolved since last review
This line changes howcausedByFontChangedis propagated toScale(...)based onIsFontSet().… The newreceivesFontChangedcheck is intended to control skipping/scaling behavior for… WithAutoScaleFactorno longer updating_currentAutoScaleFactorin its getter,… WithAutoScaleFactorno longer updating_currentAutoScaleFactorin its getter,… WithAutoScaleFactorno longer updating_currentAutoScaleFactorin its getter,… WithAutoScaleFactorno longer updating_currentAutoScaleFactorin its getter,…
Review effort: Balanced
Shyam-Gupta
left a comment
There was a problem hiding this comment.
Looks good. This is an important bug fix. Thanks.


Fixes #15331
Root cause
Two issues in font-based autoscaling cause incorrect control bounds:
Proposed changes
Customer Impact
Regression?
Risk
Before
FontIssue.mp4
After
AfterChanges.mp4
Test methodology
Test environment(s)
Microsoft Reviewers: Open in CodeFlow