C#屏幕分辨率和表格显示

我有一个C#WinForms应用程序,当我将可执行文件提供给不同的用户时,应用程序显示不同的大小(基于他们的屏幕分辨率)。 无法看到应用程序的某些部分。

无论如何根据屏幕分辨率自动调整窗口大小,还是有另一种方法?

编辑:此外,它在不同的操作系统下以不同的风格出现,是否有标准化其设计?

您可以使用Control.ScaleControl和Control.Scale

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的情况下

根据@sixlettervariables的回答, Docking和锚定当然会有所帮助。

听起来您已经使用绝对定位和其他布局默认值指定了控件。 为了使WinForms应用程序在各种大小调整场景中看起来和感觉相同并且行为正确,您需要使用Anchor和Dock属性。 在WinForms中安排控件可能是一个令人疲惫的过程,但MSDN 在这个主题上包含了一些很好的操作方法 。

我还建议遵循这篇TechRepublic文章,其中介绍了Anchoring和Docking之间的区别 ,并直观地向您展示了每个属性的完成情况:

从TechRepublic文章中锚定示例

试试这个

 private void MainForm_Load( object sender, EventArgs e ) { this.Size = Screen.PrimaryScreen.WorkingArea.Size }