C#的屏幕分辨率和表单显示 [英] C# Screen resolution and Form display

查看:203
本文介绍了C#的屏幕分辨率和表单显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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.

这篇关于C#的屏幕分辨率和表单显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆