Windows Forms DPI缩放 [英] Windows Forms DPI scaling

查看:104
本文介绍了Windows Forms DPI缩放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用DPI设置为100%时看起来不错,但是当用户选择不同的单词(125%或150%)时,这些单词就无法放入容器。我尝试使用在这里找到的解决方案来解决此问题:检测Windows字体大小(100% ,125%,150%),即:

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;

它固定了150%的设置(有点模糊,但这没关系),不幸的是,它没有对于要在应用程序上运行的PC上使用的125%而言,还是要这样做。

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?

推荐答案

创建DPI感知应用程序

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

All containers must use the same AutoScaleMode - this part fixed my problem


要求Windows应用程序在不同分辨率下应具有相同的布局,这意味着更改分辨率不会影响应用程序的布局。这是执行此操作的步骤。

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. 使用表格布局面板

  2. 将控件拖动到tablelayoutpanel并设置锚点和停靠属性。

  3. 设置拖动控件的rowpan和colspan属性以合并单元格

  4. 设置拖动控件的边距和填充

  5. 拖动所有控件并遵循相同的步骤,使用tablelayoutpanel完成设计

  6. 现在设置tablelayoutpanel的所有列和行的大小= autosize(或

  7. 设置tablelayoutpanel属性autosize = true,autosizemode =增大和缩小

  8. 设置Forms属性autosize = true,autosizemode =增大和缩小

  9. 运行Windows应用程序如果Windows应用程序以最大状态打开,则设置tablelayoutpanel扩展坞属性= fill。

  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.


这篇关于Windows Forms DPI缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆