vb.net 自动缩放 WinForm 显示(小、中)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16221317/
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
AutoScaling WinForm Display (Small, Medium)
提问by Alex
First and foremost, please forgive me but my screenshots are in French due to my Windows installation at work. It is still very easy to understand though. I'll include screenshots to make it more visually appealing.
首先,请原谅我,由于我在工作时安装了 Windows,所以我的屏幕截图是法语的。尽管如此,它仍然很容易理解。我将包括屏幕截图以使其更具视觉吸引力。
Here's some background information:
以下是一些背景信息:
- Windows 7 64bit
- Visual Studio 2010
- Default display is 100%
- AutoScaleMode: DPI
- AutoSize: True
- 视窗 7 64 位
- 视觉工作室 2010
- 默认显示为 100%
- 自动缩放模式:DPI
- 自动调整大小:真


My application is a windows form that was developped in a default (small - 100%) display. Like so:

我的应用程序是在默认(小 - 100%)显示中开发的 Windows 窗体。像这样:

As you can see, the "Petite" or Smalldisplay is the default selection.
正如你所看到的,“娇小”或小显示器是默认选择。
Small Display - 100% (default)
小显示屏 - 100%(默认)
Here is how my application looks with this setting. This is the correct display
这是我的应用程序在此设置下的外观。这是正确的显示
Medium Display - 125%
中等显示 - 125%
The red rectangles point out the unwanted empty space.

红色矩形指出不需要的空白区域。

I have tried:
我试过了:
- Anchoring/ Dockingmy controls such as my split containers, table layout panels, list views on Form_Loadandvia the UI. This didn't work.
- Adding a split container to the form, and all controls respectively separated into it
- Adding Table layout panels, where all textboxes and buttons are located in their respective cells
- 在 Form_Load 上和通过UI锚定/停靠我的控件,例如我的拆分容器、表格布局面板、列表视图。这没有用。
- 在窗体中添加一个拆分容器,所有控件分别分离到其中
- 添加表格布局面板,其中所有文本框和按钮都位于各自的单元格中
I really thought it was having a scaling problem because of the anchoring and docking. Although that didn't seem to be the problem ... What seems to be having trouble is the Tab Control and Listviews ...
由于锚定和对接,我真的认为它存在缩放问题。虽然这似乎不是问题......似乎有问题的是选项卡控件和列表视图......
Some users (most) have their settings as the default (100%) but there are a few who have it at a Medium setting, causing this scaling issue. Is there a way to fix this?
一些用户(大多数)将他们的设置设为默认值 (100%),但也有少数用户将其设置为“中等”设置,从而导致此缩放问题。有没有办法来解决这个问题?
采纳答案by Alex
I fixed my issue by putting the tab controls and list views in a tablelayoutpanel. Everything that wasn't scaled properly had to be put inside a TableLayoutPanel. I kept my AutoScaleModeto DPIand AutoSizeto True
我通过将选项卡控件和列表视图放在 tablelayoutpanel 中解决了我的问题。未正确缩放的所有内容都必须放在 TableLayoutPanel 中。我保持我的AutoScaleModetoDPI和AutoSizetoTrue
Be sure to dock everything in their parent containers.
确保将所有内容停靠在其父容器中。
Here's the document outline for the more visual (like me):
这是更直观的文档大纲(像我一样):


回答by tsiorn
I cant see your screenshots or links for some reason so I cannot visualize the problem. If scaling is the problem, try setting AutoScaleModeto None.
由于某种原因,我无法看到您的屏幕截图或链接,因此我无法想象问题。如果缩放是问题,请尝试设置AutoScaleMode为None。
I recently had to do this because my winform app was image intensive and it would not render correctly on Medium Settings because I built it using the default Small Settnigs display. Changing scale mode to Noneworked for me.
我最近不得不这样做,因为我的 winform 应用程序是图像密集型的,它无法在中等设置上正确呈现,因为我使用默认的 Small Settnigs 显示构建它。更改比例模式None对我有用。
回答by Mutebi Bashir
Just click on the form and go to property pane. Find the Anchor element and click the dropdown. You click on all the lines in the square structure to become grey. Then click enter. Problem resolved.
只需单击表单并转到属性窗格。找到 Anchor 元素并单击下拉列表。您单击方形结构中的所有线条变为灰色。然后点击进入。问题解决了。

