Skip to content

Scale the Cursor editor according to DPI - #13830

Merged
LeafShi1 merged 1 commit into
dotnet:mainfrom
LeafShi1:Fix_9007_Cursor_editor_in_propertyGrid_scale_issue
Sep 9, 2025
Merged

LeafShi1 merged 1 commit into
dotnet:mainfrom
LeafShi1:Fix_9007_Cursor_editor_in_propertyGrid_scale_issue

Conversation

@LeafShi1

@LeafShi1 LeafShi1 commented Aug 28, 2025 •

Copy link
Copy Markdown
Member

Fixes #9007

Proposed changes

  • Scale the Cursor Editor's Height as needed.
  • Update the OnDrawItem method to draw the cursor using the scaled width instead of hard-coding it.

Customer Impact

  • On High DPI environment, cursor editor in propertyGrid can be scaled well

Regression?

  • Yes

Risk

  • Minimal

Screenshots

Before

On High DPI environment, cursor editor in propertyGrid is not scaled well
image

After

On High DPI environment, cursor editor in propertyGrid can be scaled normally
image

Test methodology

  • Manually

Test environment(s)

  • .net 10.0.0-rc.1.25418.105
Microsoft Reviewers: Open in CodeFlow

@LeafShi1
LeafShi1 requested a review from a team as a code owner August 28, 2025 09:48
@LeafShi1
LeafShi1 requested review from JeremyKuhne and Copilot and removed request for a team August 28, 2025 09:49

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.

Pull Request Overview

This PR adds proper DPI scaling support to the Cursor editor in PropertyGrid to fix display issues on high DPI environments. The changes ensure the cursor editor renders correctly at different DPI scales by dynamically calculating dimensions instead of using hard-coded values.

  • Replaces hard-coded height value with DPI-aware scaling
  • Updates cursor rendering to use dynamically calculated width based on scaled icon size
  • Adjusts text positioning to account for variable cursor width

@codecov

codecov Bot commented Aug 28, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.10643%. Comparing base (8818780) to head (8525291).
⚠️ Report is 18 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #13830         +/-   ##
===================================================
- Coverage   77.10728%   77.10643%   -0.00085%     
===================================================
  Files           3273        3273                 
  Lines         644882      644884          +2     
  Branches       47688       47689          +1     
===================================================
- Hits          497251      497247          -4     
- Misses        143958      143966          +8     
+ Partials        3673        3671          -2     
Flag Coverage Δ
Debug 77.10643% <0.00000%> (-0.00085%) ⬇️
integration 18.99236% <0.00000%> (+0.00718%) ⬆️
production 51.92192% <0.00000%> (-0.00176%) ⬇️
test 97.41248% <ø> (ø)
unit 49.33910% <0.00000%> (-0.00695%) ⬇️

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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Epica3055 Epica3055 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 👍

@LeafShi1 LeafShi1 added the waiting-review This item is waiting on review by one or more members of team label Sep 5, 2025
@KlausLoeffelmann

Copy link
Copy Markdown
Member

Hey @LeafShi1,

Could you also take a look at the Anchor Editor, if it is related and maybe fixable in the same way? It also looks terrible in certain HighDPI scenarios.

Thanks!

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

Looks good to me!

@LeafShi1
LeafShi1 merged commit f7f1e07 into dotnet:main Sep 9, 2025
@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 Sep 9, 2025
@LeafShi1

LeafShi1 commented Sep 9, 2025

Copy link
Copy Markdown
Member Author
  • On High DPI environment, cursor editor in propertyGrid can be scaled well

I submitted another PR #13853 for Anchor editor, please review it.

LeafShi1 added a commit that referenced this pull request Sep 24, 2025
<!-- Please read CONTRIBUTING.md before submitting a pull request -->

Related #13830


## Proposed changes

- Update the `InitializeComponent` method to draw the Anchor Editor
using the scaled size instead of hard-coding it.

<!-- We are in TELL-MODE the following section must be completed -->

## Customer Impact

- On High DPI environment, Anchor editor in propertyGrid can be scaled
well

## Regression? 

-  No

## Risk

- Minimal

<!-- end TELL-MODE -->


## Screenshots <!-- Remove this section if PR does not change UI -->

### Before
In 300% DPI:
<img width="1783" height="750" alt="image"
src="https://github.com/user-attachments/assets/e7373f7c-db87-4b56-a370-b98e14da03aa"
/>


### After

In 300% DPI:
<img width="1281" height="846" alt="image"
src="https://github.com/user-attachments/assets/c5c7560a-fcf1-42ba-97a9-32ed69e01470"
/>


## Test methodology <!-- How did you ensure quality? -->

-  Manually


## Test environment(s) <!-- Remove any that don't apply -->

- .net 10.0.0-rc.1.25454.102


<!-- Mention language, UI scaling, or anything else that might be
relevant -->

###### Microsoft Reviewers: [Open in
CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/dotnet/winforms/pull/13853)
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 9, 2025
@LeafShi1 LeafShi1 added this to the .NET 11 milestone Dec 11, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[HDPI] Cursor editor in propertyGrid is not scaled well

4 participants