I'm working in a company that has a Winforms application as our flagship product. we recently reworked the branding and UI. We have noticed that the Forms now do not display the text properly and some controls are out of alignment or have disappeared off the edge.
Is it possible for me to make the forms on this application DPI-Aware with the least amount of re-factoring as we don't have time.
It's essential that you don't specify pixel coordinates and sizes. This rules out using Control.Top
and Control.Left
, which is what the designer does, when you "just place" the controls on a form.
To get an UI that works with different DPI settings, pretty much everything has to be dynamically sized. The controls should have Control.AutoSize
enabled. But just enabling AutoSize
would totally screw up your layout, since the control position would still be static.
To get dynamically position the controls, you can use container controls, like the FlowLayoutPanel
and the TableLayoutPanel
(with sizes set to AutoSize
). The normal controls inside of those would then just move arround the form, according to automatically determined sizes.
As you can see, this isn't simple, requires a bit of experience to get it right and needs a huge amount of testing (virtual machines with different DPI settings work great). But I think it should definitely be done, since I'm always annoyed if something looks stupid and buggy on my laptop.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With