Skip to content

Fix issue 14693: TrackBar UI control doesn't reflect properties#14697

Open
SimonZhao888 wants to merge 4 commits into
dotnet:mainfrom
SimonZhao888:Fix_Issue_14693
Open

Fix issue 14693: TrackBar UI control doesn't reflect properties#14697
SimonZhao888 wants to merge 4 commits into
dotnet:mainfrom
SimonZhao888:Fix_Issue_14693

Conversation

@SimonZhao888

@SimonZhao888 SimonZhao888 commented Jul 2, 2026

Copy link
Copy Markdown
Member

Fixes #14693

Root Cause

This issue was introduced by #8060 . TrackBar does not recreate/recalculate tick marks when TickFrequency changes after a size change, causing the native control to display an outdated number of ticks.

Proposed changes

  • Update DrawTicksManually() method to fix an off-by-one error where the last intermediate tick was missed.
  • Override the OnSizeChanged() method to prevents tick marks from retaining their original layout after the control is resized, as the control is not redrawn.

Customer Impact

  • The TrackBar UI control correctly reflects the properties.

Regression?

  • Yes

Risk

  • Mini

Screenshots

Before

image

After

14693.mp4

Test methodology

  • Manually

Test environment(s)

  • 11.0.100-preview.5.26227.104
Microsoft Reviewers: Open in CodeFlow

@SimonZhao888 SimonZhao888 marked this pull request as ready for review July 2, 2026 09:27
@SimonZhao888 SimonZhao888 requested a review from a team as a code owner July 2, 2026 09:27
@SimonZhao888 SimonZhao888 removed the draft draft PR label Jul 2, 2026

@LeafShi1 LeafShi1 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.

Thanks for the fix — the off-by-one in the tick loop is real and worth fixing. A few concerns to consider before merge:

  1. PR description vs. code mismatch. The description says "Override the OnSizeChanged() method...", but there is no OnSizeChanged/OnResize override in the diff. The resize scenario (issue #2 in #14693) actually appears to be fixed as a side effect of making the tick count size-independent (the native control rescales stored logical tick positions on resize). Please update the description to match the code, or clarify how the resize case is covered.

  2. No regression test. Since this is a runtime-only visual bug, please add a test asserting the tick count / last-interior-tick for the repro (Max=500, TickFrequency=50) so this doesn't regress again.

See inline comments for the specifics on the tick math.

Comment thread src/System.Windows.Forms/System/Windows/Forms/Controls/TrackBar/TrackBar.cs Outdated
Comment thread src/System.Windows.Forms/System/Windows/Forms/Controls/TrackBar/TrackBar.cs Outdated
Simon Zhao (BEYONDSOFT CONSULTING INC) added 2 commits July 3, 2026 13:57
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.

TrackBar UI control doesn't reflect properties

2 participants