Visual Studio 设计器向我的表单添加了边距和填充 [英] Visual Studio Designer added margin and padding to my form

查看:34
本文介绍了Visual Studio 设计器向我的表单添加了边距和填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近将我的开发工作站更新到带有 4K 显示器的 Windows 8.1,并从 Visual Studio 2010 升级到 2012.当我打开一个现有项目时,对边距和填充(默认)进行了彻底的更改.

I recently updated my development workstation to Windows 8.1 with a 4K monitor and went from Visual Studio 2010 to 2012. When I opened an existing project sweeping changes were made to Margin and Padding (were default).

Label - Margin(8, 0, 8, 0)
Button, DataGridView, TextBox, CheckBox - Margin(8, 7, 8, 7)
MenuStrip - Padding(16, 5, 0, 5)
GroupBox - Margin(8, 7, 8, 7) and Padding(8, 7, 8, 7)

控件尺寸也比以前更大.

The control Sizes are also bigger than before.

这是因为我使用的是带有显示缩放功能的 4K 显示器吗?如果是这样,我如何使用此设置控制布局.每次编辑表单时都必须更改显示分辨率吗?

Is this because I'm using a 4K monitor with display scaling? If so, how can I control layout with this setup. Do I have to change my display resolution every time I want to edit the form?

还是与 VS 2012 或 Win 8.1 有关?

Or is it something to do with VS 2012 or Win 8.1?

感谢任何帮助.

推荐答案

答案与 DPI 缩放有关.基本上,当在设计器中编辑某些东西而不是 96 DPI 时,它会被缩放.保存时,将保存缩放值.我正在以 150 DPI 编辑表单.

The answer relates to DPI scaling. Basically, when something is edited in the designer other than at 96 DPI, it is scaled. When you save, the scaled values are saved. I was editing a form at 150 DPI.

我发现 Winforms 中的 DPI 支持非常尴尬,但明智的做法似乎是在一致的 DPI 下使用设计器 - 即在同一台显示器上,最好使用 96 DPI.

I find the DPI support in Winforms to be pretty awkward but the wisdom seems to be to use the designer at a consistent DPI - i.e. on the same monitor and preferably at 96 DPI.

我确实发现在更高的 DPI 下很难获得正确的布局.我只是无法在更高的 DPI 下看到事物是否正确对齐,而在 96 DPI 时我可以清楚地看到它.因此,我无法确认坚持 96 DPI 的建议是否在技术上是必需的,但作为实践,我认为它在视觉上是必要的.

I have certainly found that it is difficult to get layout correct at higher DPI. I just can't see if things are properly aligned at higher DPI whereas I can see it clearly at 96 DPI. So, whether the advice to stick to 96 DPI is technically required or not I can't confirm but as a practice I find it visually necessary.

以下是有关如何构建 DPI Aware 应用程序的一些答案:https://stackoverflow.com/a/13228495/1439940https://stackoverflow.com/a/4076259/1439940https://stackoverflow.com/a/202172/1439940

Here are some answers about how to build DPI Aware applications: https://stackoverflow.com/a/13228495/1439940, https://stackoverflow.com/a/4076259/1439940, https://stackoverflow.com/a/202172/1439940

这篇关于Visual Studio 设计器向我的表单添加了边距和填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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