dotnet / winforms

Windows Forms is a .NET UI framework for building Windows desktop applications.
MIT License
4.28k stars 954 forks source link

Anchoring issue on multi-monitor setup using HDPI PerMonitorV2 #11516

Open alanhoman opened 2 weeks ago

alanhoman commented 2 weeks ago

.NET version

.NET 9.0 Preview 4

Did it work in .NET Framework?

Yes

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

This worked in NET 6.

Issue description

When moving the MDIParent from a 100% monitor to a 150% monitor, widening the form, closing frmNameList, then opening a new form (File -> Names), the new form is not laid out correctly. The PictureBox Custom Control is too far to the left, but was anchored Top, Right. The ListView control is too wide and overlaps with the controls to the right of it.

https://github.com/dotnet/winforms/assets/2184698/a41be26a-ba6f-48a2-b452-d78005e1631f

Steps to reproduce

  1. Run the project on a 100% monitor.
  2. Move the MDIParent to a 150% monitor.
  3. Make MDIParent wider
  4. Close frmNameList then re-open it under the menu option File -> Name.
  5. On the new form, the PictureBox Control is positioned too far to the left and inside the listview. The regular PictureBox that is not a custom control is positioned properly.
  6. The ListView control is too wide and overlaps with all of the controls to the right of it.

AnchorIssue.zip

merriemcgaw commented 2 weeks ago

We are hoping to holistically address scaling and layout in .NET 10. There is no real way to address these piece by piece we've determined, so we intend to look at layout from the ground up in a near future release.

alanhoman commented 2 weeks ago

This sounds promising and I hope this is a high priority considering how many people use multiple monitors at varying DPI’s and scaling %. The HDPI issues were originally slated to be addressed in .NET 6, 7, 8, and 9, so we have been waiting 4 years for a solution. This has prevented us from being able to migrate from .NET Framework to .NET. Our main app has over 2,500 forms, so moving to WPF or MAUI is not an option at this point. I hope that this holistic approach will not utilize the AnchorLayoutV2 approach which basically fixed one thing and broke multiple other things making it unusable to us.

I would be interested in early testing and evaluation so please let me know if I can be of help in any way.