My application looks good with 100% DPI setting, but when user selects different (125% or 150%) words don't fit in containers. I tried to fix this with solution I found here: Detect windows font size (100%, 125%, 150%) which is:
this.AutoScaleMode = AutoScaleMode.Dpi;
It fixed 150% setting (made it a little blur, but that's ok), unfortunately it didn't make the same for 125% which is being used on the PC the app is intended to run.
Is there some easy fix to this or do I have to rearrange every form manually?
There are three options to resolve the display problem: Restart Visual Studio as a DPI-unaware process. Add a registry entry. Set your display scaling setting to 100%
Alternatively, right click on an empty area on your desktop and select Display. In System, settings screen click on Displayoption from left side. Under Change the size of text, apps, and other items: 100% (Recommended), move the slider left or right to the DPI percentage you want to set for that display.
To make your application dpi-aware, you must cancel automatic dpi scaling, and then adjust user interface elements to scale appropriately to the system dpi.
Creating a DPI-Aware Application
All containers must use the same AutoScaleMode - this part fixed my problem
It is required that windows app should have same layout at different resolutions means there should be no effect on layout of app on changing resolution. Here are the steps to do this.
- Use table layout panel
- Drag control in cell of tablelayoutpanel and set anchor and dock property.
- Set rowspan and colspan properties of dragged control to merge cells
- Set margin and padding of dragged control with respect to cell.
- drag all controls and follow same steps, complete design using tablelayoutpanel
- Now set all columns and rows size of tablelayoutpanel = autosize (or in %)
- Set tablelayoutpanel properties autosize = true,autosizemode = grow and shrink
- Set Forms properties autosize = true,autosizemode = grow and shrink
- Run windows app If your windows app opens in maximum state then set tablelayoutpanel dock property =fill.
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