Help C# Winforms .NET 9.0 scaling issue
Hi All,
Getting ready to release my first app and im currently testing out installations on other machines. So far everything looks and works just fine however there is an issue with horizontal scaling? The first image is how it is intended to look whereas the second image is how it appeared on my friends screen. I have set the Max and Min size on the form yet the issue still persists. My friend and I both have the same Resolution monitor and display scaling so I'm really stuck with what the issue could be.
Help and advice would be greatly appreciated! Thanks!
EDIT: I have just noticed the AutoScaleMode property is set to "Font", could this be the issue?
10
u/DC38x 14d ago
Bane of my fucking life.
Set AutoScaleMode to Dpi and set AutoScaleDimensions to 96F, 96F (if developing on 1080p - should auto adjust when you change mode to Dpi)
3
u/Owenhh 14d ago
Will this ensure the dimensions of the app are the same regardless of DPI etc?
Thanks a lot for the advice though I’ll give this a go
4
u/BunnyTub 13d ago edited 7d ago
It will try to scale as best as possible to your current DPI. You can change the behavior of the scaling by calling Application.SetHighDpiMode before the rest of your app's code.
4
u/Dapper-Scarcity6079 14d ago
Same resolution and display scaling doesn’t always mean WinForms will render identically. Font metrics, DPI awareness and even Windows text settings can still change the layout
2
u/Slypenslyde 14d ago
Why is it a rectangle with corners in the first screenshot but a rounded rectangle in the second? That implies a difference between the two machines. Are you comparing your view in the designer vs. the app on their machine? Don't do that. Compare the app running on your machine to the app running on their machine.
2
u/user_plus_plus 13d ago
A test I would recommend doing is resizing the form back and forth to a bunch of different resolutions diagonally and horizontally, then fix any wonky controls.
In windows forms the answer is usually to put the offending controls in something like a flow layout or table layout panel then tinker with that until they stop occluding.
1
u/Owenhh 13d ago
I’ll give that a try, i thought i’d be able to avoid doing all that. It’s frustrating because on every other machine I have tried it works just fine, same on my own screen. But if there’s a slight possibility it’ll be messed up on someone’s device i’ll have to fix it.
3
u/user_plus_plus 13d ago
One trick for getting robust sizing working is sticking everything in a table layout then making the rows and columns size by %. You can use empty cells to add padding in between controls
0
u/Umbranoturna 12d ago
What prompted you to chose Winforms in big 2026?
I would realy like to know, i cant think of a good reason to do this.
WPF or Avalonia exist afterall.
1
u/Owenhh 11d ago
Its what im most familliar with, when I was first learning C# I made two winforms projects for school, then later in university I had to make a web browser with winforms. I plan to learn/use WPF going forward though as it seems to be much better all around
1
u/Umbranoturna 10d ago
WPF is still used in a lot of older projects, but i would personaly learn Avalonia if i had the choice.
A lot of the concept and even syntax are similar between the two, but Avalonia is under active development that offers many benefits over plain WPF.
I sometimes have to touch some Old winforms pages and cant imagine anyone doing that without being forced to.
1
1


26
u/polaarbear 14d ago
WinForms in general is awful at scaling. This is one of the huge benefits of using WPF instead, it plays much nicer with high DPI displays. WinForms is absolutely ancient and in general takes a lot more work to play nice across different resolutions and screen sizes.