c# - Windows 窗体 DPI 缩放

标签 c# winforms dpi

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/

相关文章:

c# - 自动缩放但仍在处理 WM_DPICHANGED

c# - 查找在多个句子中重复出现的三个最常见单词数组的算法

javascript - C# MVC5 ValidationMessageFor使用jquery datetimepicker抛出 "The field must be a date."

c# - 委托(delegate)/事件 winform c# 不工作 - 订阅者/监听器始终为空

java - 使用 Java Swing 打印

android - 为不同的 Android 屏幕尺寸/密度缩放 Phonegap 应用程序?

c# - 将视频从 pi 相机流式传输到 unity 项目

c# - 从 WebApi 中的 json 对象列表中删除引用 $id

c# - 在 C# WinForms 应用程序中启动后台线程的合适位置在哪里?

c# - 亡灵形态仍在产生事件