Fix issue 14693: TrackBar UI control doesn't reflect properties#14697
Fix issue 14693: TrackBar UI control doesn't reflect properties#14697SimonZhao888 wants to merge 10 commits into
Conversation
LeafShi1
left a comment
There was a problem hiding this comment.
Thanks for the fix — the off-by-one in the tick loop is real and worth fixing. A few concerns to consider before merge:
-
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.
-
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.
There was a problem hiding this comment.
Pull request overview
Fixes a regression in WinForms TrackBar tick rendering when falling back to the manual tick-rendering path, aiming to make drawn ticks consistently reflect TickFrequency across range/size changes.
Changes:
- Adds validation/message resources for invalid
TickFrequencyvalues (rejects negatives; intends to allow0). - Reworks
DrawTicksManually()to compute tick positions deterministically and adjust drawing based on control size. - Adds localized resource entries for the new
TickFrequencyerror string.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/System.Windows.Forms/System/Windows/Forms/Controls/TrackBar/TrackBar.cs | Updates TickFrequency validation and revises manual tick calculation/loop. |
| src/System.Windows.Forms/Resources/SR.resx | Adds TrackBarTickFrequencyError string. |
| src/System.Windows.Forms/Resources/xlf/SR.cs.xlf | Adds localized entry for TrackBarTickFrequencyError. |
| src/System.Windows.Forms/Resources/xlf/SR.de.xlf | Adds localized entry for TrackBarTickFrequencyError. |
| src/System.Windows.Forms/Resources/xlf/SR.es.xlf | Adds localized entry for TrackBarTickFrequencyError. |
| src/System.Windows.Forms/Resources/xlf/SR.fr.xlf | Adds localized entry for TrackBarTickFrequencyError. |
| src/System.Windows.Forms/Resources/xlf/SR.it.xlf | Adds localized entry for TrackBarTickFrequencyError. |
| src/System.Windows.Forms/Resources/xlf/SR.ja.xlf | Adds localized entry for TrackBarTickFrequencyError. |
| src/System.Windows.Forms/Resources/xlf/SR.ko.xlf | Adds localized entry for TrackBarTickFrequencyError. |
| src/System.Windows.Forms/Resources/xlf/SR.pl.xlf | Adds localized entry for TrackBarTickFrequencyError. |
| src/System.Windows.Forms/Resources/xlf/SR.pt-BR.xlf | Adds localized entry for TrackBarTickFrequencyError. |
| src/System.Windows.Forms/Resources/xlf/SR.ru.xlf | Adds localized entry for TrackBarTickFrequencyError. |
| src/System.Windows.Forms/Resources/xlf/SR.tr.xlf | Adds localized entry for TrackBarTickFrequencyError. |
| src/System.Windows.Forms/Resources/xlf/SR.zh-Hans.xlf | Adds localized entry for TrackBarTickFrequencyError. |
| src/System.Windows.Forms/Resources/xlf/SR.zh-Hant.xlf | Adds localized entry for TrackBarTickFrequencyError. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fixes #14693
Root Cause
This regression came from the manual tick-rendering path introduced in #8060.
When TrackBar falls back to DrawTicksManually(), the tick math had two issues:
Proposed changes
Customer Impact
Regression?
Risk
Screenshots
Before
After
14693.mp4
14693-1.mp4
14693-2.mp4
Test methodology
Test environment(s)
Microsoft Reviewers: Open in CodeFlow