gpt4 book ai didi

c# - Windows 窗体 DPI 缩放

转载 作者:可可西里 更新时间:2023-11-01 08:25:53 24 4
gpt4 key购买 nike

enter image description here

我的应用程序在 100% DPI 设置下看起来不错,但是当用户选择不同的(125% 或 150%)时,单词不适合容器。我试着用我在这里找到的解决方案来解决这个问题:Detect windows font size (100%, 125%, 150%)这是:

this.AutoScaleMode = AutoScaleMode.Dpi;

它修复了 150% 的设置(让它有点模糊,但没关系),不幸的是,它没有为 125% 设置相同的设置,该设置在应用程序打算运行的 PC 上使用。

是否有一些简单的解决方法,或者我是否必须手动重新排列每个表单?

最佳答案

Creating a DPI-Aware Application

所有容器必须使用相同的 AutoScaleMode - 这部分解决了我的问题

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.

关于c# - Windows 窗体 DPI 缩放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26073635/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com