Skip to content

Fix UpDown buttons scaling incorrectly on DPI changes - #15207

Merged
SimonZhao888 merged 3 commits into
dotnet:mainfrom
LeafShi1:Fix_14784_Up/Down_buttons_scale_incorrectly
Nov 10, 2026
Merged

SimonZhao888 merged 3 commits into
dotnet:mainfrom
LeafShi1:Fix_14784_Up/Down_buttons_scale_incorrectly

Conversation

@LeafShi1

@LeafShi1 LeafShi1 commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Fixes #14784

Proposed changes

Update UpDownBase.OnParentFontChanged to:

  • Set the control height to PreferredHeight.
  • Recalculate _defaultButtonsWidth based on the current device DPI.

Customer Impact

  • The Up/Down buttons of DomainUpDown and NumericUpDown can be incorrectly sized after changing the display scaling or moving the application between monitors with different DPI settings.

Regression?

  • No

Risk

  • Minimal

Screenshots

Before

The Up/Down buttons could scale incorrectly after a DPI change. For example, the buttons could become larger when scaling down or smaller when scaling up.

Recording.2026-07-20.021407.mp4

After

The control height and default buttons width are recalculated after the parent font changes, and the Up/Down buttons scale correctly with the current DPI.

AfterChanges.mp4

Test methodology

  • Manually

Test environment(s)

  • .net 12.0.0-beta.26478.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.

Copilot review overview

🟡 Changes recommended

The implementation leaves button layout stale, overrides supported custom heights, and lacks regression coverage.

Review effort: Balanced
Findings: 1 Medium severity · 1 Low severity

Open (2)
What changed in this PR

Updates UpDownBase DPI/font handling to recalculate control and button dimensions.

Changes:

  • Adds parent-font-change scaling logic.
  • Records the protected override in the public API baseline.
File Description
UpDownBase.cs Recalculates height and button width.
PublicAPI.Unshipped.txt Adds the new override signature.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@codecov

codecov Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 37.84861%. Comparing base (f01cd30) to head (0b90404).
⚠️ Report is 13 commits behind head on main.

Additional details and impacted files
@@              Coverage Diff              @@
##                main      #15207   +/-   ##
=============================================
  Coverage   37.84861%   37.84861%           
=============================================
  Files            246         246           
  Lines           9789        9789           
  Branches        1031        1031           
=============================================
  Hits            3705        3705           
  Misses          5920        5920           
  Partials         164         164           
Flag Coverage Δ
Debug 37.84861% <ø> (ø)
production 40.04608% <ø> (ø)
test 20.64923% <ø> (ø)
unit 40.04608% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Copilot review overview

🟡 Changes recommended

Existing unresolved feedback identifies stale button layout, loss of explicit modern-mode heights, and missing regression coverage.

Review effort: Balanced
Findings: 1 Medium severity · 1 Low severity

Open (2)

@LeafShi1
LeafShi1 marked this pull request as ready for review October 14, 2026 03:22
@LeafShi1
LeafShi1 requested a review from a team as a code owner October 14, 2026 03:22
@LeafShi1 LeafShi1 added waiting-review This item is waiting on review by one or more members of team and removed draft draft PR labels Oct 14, 2026

@SimonZhao888 SimonZhao888 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me!

@KlausLoeffelmann KlausLoeffelmann left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes.
Let's please also backport this to .NET 11 - because it can screw up layout and cascade things up on for example A11Y TextSize changes.

@SimonZhao888
SimonZhao888 merged commit a9d9226 into dotnet:main Nov 10, 2026
8 checks passed
@dotnet-policy-service dotnet-policy-service Bot removed the waiting-review This item is waiting on review by one or more members of team label Nov 10, 2026
SimonZhao888 pushed a commit to KlausLoeffelmann/winforms that referenced this pull request Nov 10, 2026
* Fix UpDown buttons scaling incorrectly on DPI changes

* Addoverride System.Windows.Forms.UpDownBase.OnParentFontChanged 同PublicAPI

* Add unit test
@LeafShi1
LeafShi1 deleted the Fix_14784_Up/Down_buttons_scale_incorrectly branch November 11, 2026 02:47
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 11, 2026
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.

Up/Down buttons of the DomainUpDown/NumericUpDown control scale incorrectly at different DPI

4 participants