dotnet / dotnet/winforms

Groupbox incorrectly scale on the high DPI devices when AutoScaleMode is set to DPI

Open
#9,293 17 comments 2 reactions 0 assignees View on GitHub
area-Anchor/Scaling area-HDPI
Dominant language
C#
Stars
4.9k
Forks
1.1k
Avg merge
20h 23m
Merged PRs (30d)
103

Description

### .NET version

.Net 6

### Did it work in .NET Framework?

Yes

### Did it work in any of the earlier releases of .NET Core or .NET 5+?

No

### Issue description

The WinForm dialog display incorrectly in the high DPI(>100%) see the screenshot:
![displayError](https://github.com/dotnet/winforms/assets/23306796/07298380-2a21-40e1-ab02-6394d8965b52)
This is the correct display:
![displayCorrectly](https://github.com/dotnet/winforms/assets/23306796/ca736be4-6ef7-4594-9276-5e84aed4daf3)
But if I add a `Font = Font` or `Scale(new SizeF(1.0F,1.0F))` to the end of `InitializeComponent`, we can get the right display again:
![DisplayCorrectlyAfterFix](https://github.com/dotnet/winforms/assets/23306796/afa5d8b2-7073-45fc-888b-64087fd38c65)

So why do I need the extra code to make it display correctly? We just migrated our code to .net 6 from .net 4.8. There are no these situations on the .net framework 4.8. Did we have any solution to handle this on the high DPI?

### Steps to reproduce

Create a new WinForm project (.net 6)
Use a groupbox, and fill in some checkboxes.
Set the dialog's AutoScaleMode to Dpi.
Building.
Set the system Scale to 200% (system settings ->Display -> Scale and layout).
Open the new exe.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.