Afn*_*hir 44 c# user-interface resize screen-resolution winforms
我注意到一些应用程序改变了它们的控件位置,以尽可能在分辨率中调整它们.如果窗口最大化,它们将自己设置为在所有GUI看起来均衡的方式.我的问题是,是否可以在Visual Studio 2010 C#中制作或实现此功能?
Bha*_*kar 19
使用这些组合来获得所需的结果:
将Anchor属性设置为None,控件不会调整大小,它们只会移动它们的位置.
将Anchor属性设置为Top + Bottom + Left + Right,控件将调整大小但不会更改其位置.
将Minimum Size表单设置为适当的值.
设置Dock财产.
使用Form Resize事件来改变你想要的任何东西
我不知道(1) - (4)中字体大小(标签,文本框,组合框等)会受到什么影响,但可以在(5)中控制.
小智 10
float widthRatio = Screen.PrimaryScreen.Bounds.Width / 1280;
float heightRatio = Screen.PrimaryScreen.Bounds.Height / 800f;
SizeF scale = new SizeF(widthRatio, heightRatio);
this.Scale(scale);
foreach (Control control in this.Controls)
{
control.Font = new Font("Verdana", control.Font.SizeInPoints * heightRatio * widthRatio);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
189426 次 |
| 最近记录: |