简体   繁体   中英

Windows Forms DPI scaling

在此输入图像描述

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?

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.

  1. Use table layout panel
  2. Drag control in cell of tablelayoutpanel and set anchor and dock property.
  3. Set rowspan and colspan properties of dragged control to merge cells
  4. Set margin and padding of dragged control with respect to cell.
  5. drag all controls and follow same steps, complete design using tablelayoutpanel
  6. Now set all columns and rows size of tablelayoutpanel = autosize (or in %)
  7. Set tablelayoutpanel properties autosize = true,autosizemode = grow and shrink
  8. Set Forms properties autosize = true,autosizemode = grow and shrink
  9. Run windows app If your windows app opens in maximum state then set tablelayoutpanel dock property =fill.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM