我有一个C#WinForms应用程序,当我给可执行不同用户的应用程序将显示不同大小(根据其屏幕分辨率)。一些应用程序的各部分的不能被看到。
I have a C# WinForms application and when I give the executable to different users the application displays in different sizes (based on their screen resolution). Some of the parts of the application can't be seen.
反正有自动调整大小根据屏幕分辨率的窗口,或者是有其他的方法呢?
Is there anyway to auto-size the window based on the screen resolution, or is there another approach?
编辑:此外,它会出现在不同风格下的不同的操作系统,有没有去规范它的设计
EDIT : furthermore it appears in different styles under different Operating systems, is there away to standardize its design ?
您可以使用的 Control.ScaleControl 和控制。规模
private void MainForm_Load( object sender, EventArgs e )
{
float width_ratio = (Screen.PrimaryScreen.Bounds.Width / 1280);
float heigh_ratio = (Screen.PrimaryScreen.Bounds.Height / 800f);
SizeF scale = new SizeF(width_ratio, heigh_ratio);
this.Scale(scale);
//And for font size
foreach (Control control in this.Controls)
{
control.Font = new Font("Microsoft Sans Serif", c.Font.SizeInPoints * heigh_ratio * width_ratio);
}
}
在的情况下,当开发平台的分辨率是1280×800
In the case when the development platform resolution is 1280x800
据@sixlettervariables的答案停靠和锚定将有助于当然。
According to @sixlettervariables 's answer Docking and anchoring will help of course.
上一篇:我在哪里可以找到转义字符的MSIL字符串常量列表?我在、常量、字符串、可以找到
下一篇:从类型'System.String'的输入'X'的参数转换失败,因为没有类型转换器可在这些类型之间的转换类型、可在、转换器、参数