Fix Issue 14167: [HDPI] Cursor editor some items are not displayed in propertyGrid with special DPI settings - #15049
Fix Issue 14167: [HDPI] Cursor editor some items are not displayed in propertyGrid with special DPI settings#15049SimonZhao888 wants to merge 3 commits into
Conversation
… propertyGrid with special DPI settings
There was a problem hiding this comment.
🟡 Changes recommended
The new owner-draw path should acquire the HDC via DrawItemEventArgs (IHdcContext/IGraphicsHdcProvider) to preserve WM_DRAWITEM DC state/clipping and avoid unnecessary Graphics↔HDC state churn.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR addresses HDPI rendering issues in the PropertyGrid cursor dropdown by ensuring the icon column width is computed using the widest standard cursor at the current DPI, preventing truncation/overlap for wider cursors.
Changes:
- Recompute the shared cursor icon column width as the maximum width across all standard cursors for the active DPI.
- Adjust owner-draw rendering logic and add redraw hooks to improve first-paint correctness when the dropdown becomes visible.
- Add unit tests validating
_cursorWidthselection logic, cache rebuild behavior, and graphics clip restoration.
File summaries
| File | Description |
|---|---|
| src/System.Windows.Forms.Design/src/System/Drawing/Design/CursorEditor.CursorUI.cs | Recalculates uniform cursor column width from the standard cursor set and updates owner-draw rendering/redraw behavior. |
| src/System.Windows.Forms.Design/tests/UnitTests/System/Drawing/Design/CursorEditorTests.cs | Adds regression tests for widest-cursor width selection, cache rebuild on Start/End, and clip restoration during drawing. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #15049 +/- ##
=============================================
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 #14167
Root Cause
The issue with the CurSor icon offset was introduced by #14575. CursorEditor.CursorUI uses a "uniform icon column width" when drawing Cursor dropdowns, but this width is only calculated based on Cursors.Default.
At high DPI or with certain cursors (such as NoMove2D / NoMoveHoriz / NoMoveVert / HSplit / VSplit), the actual drawn width may be greater than this column width, causing icons to go out of bounds, overlap with text areas, or appear truncated.
Proposed changes
The calculation logic for shared icon column width has been changed from "only Cursors.Default" to "the maximum width of all standard Cursors at the current DPI":
_cursorWidthto draw each row, maintaining consistent column alignment._cursorWidthequals the maximum width in the standard Cursor set.Customer Impact
Regression?
Risk
Screenshots
Before
After
125%
Recording.2026-09-07.145716.mp4
150%
Recording.2026-09-07.151123.mp4
175%
Recording.2026-09-07.150053.mp4
225%
Recording.2026-09-07.150421.mp4
350%
Recording.2026-09-07.151411.mp4
Test methodology
Accessibility testing
Test environment(s)
Microsoft Reviewers: Open in CodeFlow