winforms icon indicating copy to clipboard operation
winforms copied to clipboard

[HDPI] SystemAware controls inside containers anchored with Bottom or Right are messed up.

Open kirsan31 opened this issue 2 months ago • 4 comments

.NET version

.Net9

Did it work in .NET Framework?

Not tested/verified, but I think - NO.

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

Not working with .Net8, and I think with oldest too.

Issue description

Form designed and launched with 125% dpi: Image

If AnchorStyles.Bottom is used then problems are more huge: Image

Image

This is one of more others issues with anchoring Bottom / Right and HDPI: https://github.com/dotnet/winforms/issues/5076 https://github.com/dotnet/winforms/issues/8157 https://github.com/dotnet/winforms/issues/10958 https://github.com/dotnet/winforms/issues/11516 ...

Setting:

{
  "configProperties": {
    "System.Windows.Forms.AnchorLayoutV2": true
  }
}

in runtimeconfig.template.json will solve the issues.

Steps to reproduce

TabControlAnchorBug.zip

kirsan31 avatar Nov 10 '25 09:11 kirsan31

@kirsan31 using the below configurations can make the controls inside containers scaled well.

{
  "configProperties": {
    "System.Windows.Forms.AnchorLayoutV2": true
  }
}

https://github.com/user-attachments/assets/a6f475fa-2aa8-4059-be9b-e6c99c08a931

Zheng-Li01 avatar Nov 11 '25 02:11 Zheng-Li01

@Zheng-Li01 wow thanks. You are right AnchorLayoutV2 resolve this issues. I completely missed everything related to AnchorLayoutV2 and it's clear why - there no any mentions about it in what's new for .Net8 🤷‍♂️ Google (except AI) also find almost nothing. And only after searching this repo I found the article: https://github.com/dotnet/winforms/blob/main/docs/design/anchor-layout-changes-in-net80.md

kirsan31 avatar Nov 11 '25 08:11 kirsan31

@Zheng-Li01 the instructions need more context, I believe I need to add a new file runtimeconfig.template.json in the same directory as my project file (if it does not exist) and then add or merge the JSON content above.

As @kirsan31 said this was very difficult to discover.

paul1956 avatar Nov 11 '25 17:11 paul1956

Using WinForms for ages and never heard of this switch...

Balkoth avatar Nov 12 '25 07:11 Balkoth