如何确定表格大小属性以适合目标PC的显示器 [英] how to decide the Form size property to fit with the target PC's Monitor

查看:58
本文介绍了如何确定表格大小属性以适合目标PC的显示器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在PC上使用C#2010开发了一个应用程序.它具有多种形式.我在代码中以及Forms的size属性中定义了表单大小(宽度= 1285,高度= 950).这对于我开发应用程序的PC来说效果很好.但是,当我将应用程序安装到另一台具有不同显示器分辨率和不同显示器尺寸的PC上时,表格无法正确显示.表格的某些部分不可见.

我如何使表格适合任何PC,无论其大小或分辨率如何.我使用的代码如下所示

I developed an application in C#2010 in my PC. it have many forms .I have defined the forms size (width=1285,Height=950) in the code ,and in the size property of Forms . this worked fine for the PC in which I developed the Application. but when I install the application to another PC which is having different monitor resolution and different monitor size the form is not displayed properly. some portion of the form not visible.

how I can make the form to fit to any PC,Monitor irrespective of its size or resolution.the code I used is shown below

 private void MC_Load(object sender, EventArgs e)
        {
            this.Width = 1285;
            this.Height = 950;
            Point p = new Point(0, 0);
            this.Location = p;

}

推荐答案

在表单中的控件上使用锚点,对齐方式和停靠属性.

http: //stackstackflow.com/questions/174355/how-do-i-resize-my-panels-how-do-i-resize-my-panels-when-resizing-the-main-form-in-a-winforms-application [ http://msdn.microsoft.com/en-us/library/8y52cxte%28v = vs.80%29.aspx [ ^ ]

http://www.voidspace.org.uk/ironpython/winforms/part7.shtml [ ^ ]
Use anchors, alignments and dock properties on your controls in your forms.

http://stackoverflow.com/questions/174355/how-do-i-resize-my-panels-when-resizing-the-main-form-in-a-winforms-application[^]

http://msdn.microsoft.com/en-us/library/8y52cxte%28v=vs.80%29.aspx[^]

http://www.voidspace.org.uk/ironpython/winforms/part7.shtml[^]


始终将表单设计为屏幕尺寸的最小规格,然后使用Mehdi建议的锚点和对齐方式来帮助正确调整表单的大小.放大设计总是比缩小设计容易,这就是为什么我建议您这样做的原因.
Always design your forms to a minimum specification of screen size and then use the anchors, alignments as Mehdi suggests to help the form resize properly. It is always easier to scale up a design than to scale down which is why I suggest you do it this way.


这篇关于如何确定表格大小属性以适合目标PC的显示器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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