问题描述
我知道这是重复的问题,但我检查了所有其他相关问题,他们的回答没有帮助(结果仍然与屏幕截图 2 中所示相同)
I know this is duplicated question but I checked all other related question and their answers did not help ( the result still the same as shown in screenshot 2)
我是 C# windows 窗体的新手.如screenshot1 所示,我有Form1
和一些控件,每组控件都放在一个面板中.我在 PC1 中设计了应用程序,如 Screenshot1 所示,它适合屏幕分辨率并且运行良好.
I am new to c# windows forms. As shown in screenshot1, I have Form1
with some controls and each group of controls were put in a panel. I designed the application in PC1 as shown in Screenshot1 which is fit the screen resolution and worked well.
我的应用程序是在 1366 x 768 屏幕分辨率下开发的(如屏幕截图 1 所示),但是当我在不同显示器尺寸和不同屏幕分辨率的不同计算机 (PC2) 上运行此应用程序时,表单显得太大,应用程序的一部分是丢失或不在屏幕上.
My application was developed in 1366 x 768 screen resolution (as shown in Screenshot1) but when I run this application in different computer (PC2) with different monitor size and different screen resolution the form appeared too big and part of the application is missing or is out of the screen.
然而,我使用 Anchors 解决了这个问题,但出现了另一个问题,即:用户控件不会重新调整自身大小(如截图 2 所示),并且它的一部分被剪切或进入 panel1 .不知道问题是与用户控件有关还是与Form1中的所有控件有关(它们应该自己调整大小)
However I solved this issue using Anchors but another issues came up which is: the user control does not re-size itself ( as shown in screenshot2) and part of it is cut or went under panel1 . I do not know if the problem is related to user control or related to all controls in Form1 (they should resize themselves)
我什至尝试了以下代码,但结果仍然相同:
I even tried the following code but the result still the same:
this.WindowState = FormWindowState.Maximized;
this.Location = new Point(0, 0);
this.Size = Screen.PrimaryScreen.WorkingArea.Size;
Screen.PrimaryScreen.WorkingArea
我昨天一整天都在寻找解决这个问题的方法,但我失败了,请帮助我提出任何可能有用的想法/建议.谢谢
I have been searching to solve this issue the whole day yesterday but I failed, Please help me with any idea/suggestion it might work. Thank you
推荐答案
如果您正在使用 Windows 窗体并且您无法切换到 WPF,那么您将更愿意以最低的分辨率进行所有设计,您必须以该分辨率运行.
If you are working with Windows Forms and you cannot switch to WPF then you will prefer to do all the design in the lowest resolution at which you must run.
在 WinForms 中,您要设置每个元素的大小,因此它们不会根据应用程序大小重新调整大小.它们将要做的是沿着空白空间分布(如果您对它们进行编程),从而增加它们之间的自由空间,仅此而已.
In WinForms you are setting the Size of every element so they will not re size according to the app size. What they will do is to be distributed along the empty space (if you program them to do so) increasing the free space between them, that's all.
另一种选择是 LayoutPanels,正如 Sinatr 所说,他们试图提供 WPF 面板功能.
Another option are LayoutPanels as Sinatr said as they try to offer the WPF panel functionality.
这篇关于如何适应/重新调整 Windows 窗体的大小以适应任何屏幕分辨率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!