如何调整窗户形式 [英] How to adjust the windows forms

查看:86
本文介绍了如何调整窗户形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在创建一个Windows应用程序,所有程序都运行成功,我的显示器大小为17英寸,但安装的其他系统无法容纳屏幕尺寸的表格.如何解决.

Hi,

I am create a windows application all are running successfully,my moniter size LCD 17 inch,but installed the other system cannot fit the forms in screen size.How to solve it.

推荐答案

首先,您最好确保表格适合屏幕.为此,请使用类System.Windows.Forms.Screen:
http://msdn.microsoft.com/en-us/library/system. windows.forms.screen.aspx [ ^ ].

调整表格的侧面和位置以适合屏幕.

您将需要设计表单布局,使其在调整大小时表现良好.如果设计正确,则不需要处理事件System.Windows.Forms.Contol.Resize.达到这种质量的一些好的规则包括:1)永远不要使用手动定位控件; 2)使用嵌套面板,对接(基于System.Windows.Forms.Control.Dock属性和填充;在某些情况下Anchors帮助; 3)使用Splitter,但将其使用限制在必要的最低限度; 4)为属性MinimumSize(很少是MaximumSize)使用正确的值.

我的最后一条规则使一些开发人员发疯,但无论如何我都会分享:将设计人员的使用保持在最低限度.我建议仅使用它来放置主要清晰可见的元素,例如主菜单,状态栏和所有面板,并在代码中完成所有其余工作. Designer意味着很多容易出错的手动工作(单击,单击,重复多次),如果正确执行代码,则编写代码可以是高度可靠和简约的.

—SA
First of all, you should better make sure your form fits the screen. For this purpose, use the class System.Windows.Forms.Screen:
http://msdn.microsoft.com/en-us/library/system.windows.forms.screen.aspx[^].

Adjust the form''s side and position to fit the screen.

You will need to design form layout the way it behave nicely when it is resized. When it is designed correctly, no handling of the event System.Windows.Forms.Contol.Resize is required. Some good rules used to achieve this quality include: 1) never use manual positioning of control; 2) use nested panels, docking (based on System.Windows.Forms.Control.Dock property and padding; in some cases Anchors help; 3) use Splitter but keep its use to a necessary minimum; 4) use correct values for the properties MinimumSize (rarely MaximumSize).

My last rule drives some developers crazy, but I''ll share it anyway: keep the use of the designer to a bare minimum. I would advise to use it only to put main clearly visible elements such as main menu, status bar and all the panel, do all the rest in code. Designer means a lot of manual error-prone work (click, click, repeat many times), writing code can be highly reliable and minimalistic if done in a right way.

—SA


停靠当然可以提供帮助.只需在控件的属性"中查看,您希望如何独立于分辨率并设置停靠,然后在窗体显示时控件也会自动调整大小.
有关更多信息,请参见此CP文章;
Anchoring, Docking Windows窗体中控件的属性:
使用锚固和对接属性 [ ^ ]

锚定和停靠子控件 [锚定和停靠子控件 [当屏幕分辨率改变时,Zom Out发生故障 [ ^ ]
GUI外观-C#.Net [如何停靠按钮,以便它可以使用以下格式进行调整 [
Docking can help of course. Just look in the Properties of the control how you want to be resolution independent and set the docking, then the control automatically resizes too when the form does.
For more please see this CP article;
Anchoring, Docking Properties of Controls in Windows Forms:
Working with Anchoring and Docking Properties[^]

Anchor and Dock Child Controls[^]
Anchor and Dock Child Controls[^]

Also have look on similar discussions, you will get surely needful from them:
Zom Out malfunctions when Screen resolution changes[^]
GUI Apperance - C#.Net[^]
how to dock button so that it can adjust with the form[^]

Hope it helps!


这篇关于如何调整窗户形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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