vb.net 当用户将显示设置为中 (125%) 时,文本框/表单项被截断

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15228356/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 12:37:14  来源:igfitidea点击:

Textboxes/form items are being cut off when user has the display set to Medium (125%)

c#vb.netwinforms

提问by user889829

I have a Windows Formapplication written in VB.net. My users are telling me that when they go to Control Panel > Displayand set their “size of text” to Medium (125%), TextBoxes and DropDown boxes on the Form are getting cut off. I have set the AutoScaleModeon the Form to DPI but that is not helping. Any Ideas?

我有一个用 VB.net 编写的Windows 窗体应用程序。我的用户告诉我,当他们转到“控制面板”>“显示”并将“文本大小”设置为“中”(125%) 时,表单上的文本框和下拉框会被截断。我已将表单上的AutoScaleMode设置为 DPI,但这无济于事。有任何想法吗?

回答by Dave Doknjas

There are a couple of different approaches you can take:

您可以采取几种不同的方法:

  1. Change the AutoScaleMode setting on all your forms and user controls to 'None' and just ensure that your labels etc. are long enough to handle the text of your UI in the most common DPI settings. e.g., test for various DPI - if it works for 100%, 125%, & 150% you'll be in pretty good shape.

  2. Switch to WPF (much easier said than done).

  3. Try to get it working with AutoScaleMode set to DPI - this is very hard to do - if you research this you'll find that it is not trivial to get this working right.

  1. 将所有表单和用户控件上的 AutoScaleMode 设置更改为“无”,并确保您的标签等足够长以在最常见的 DPI 设置中处理您的 UI 文本。例如,测试各种 DPI - 如果它适用于 100%、125% 和 150%,您将处于良好状态。

  2. 切换到 WPF(说起来容易做起来难)。

  3. 尝试让它在 AutoScaleMode 设置为 DPI 的情况下工作 - 这很难做到 - 如果你研究这个,你会发现让它正常工作并非易事。