做最好的办法的WinForms调整大小? [英] Best way to make winforms resizable?

查看:98
本文介绍了做最好的办法的WinForms调整大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个相当大的C#项目有很多的WinForms,尽管你可以调整的形式,形式要素不具有可扩展。

I am working on a largish c# project with a lot of winforms that, even though you can resize the form, the elements in the form don't scale.

我怎样才能让表单元素(如datagridview的,文本区的,等等),当用户改变窗体的大小尺度

How can I make the form elements (such as the datagridview, text area's, etc) scale when the user changes the size of the form.

几乎所有的从一个特定的形式形式的子类,所以如果有什么东西我可以在基类做,那简直太好了。

Nearly all the forms subclass from one specific form so if there's something I can do in the base class, that'd be great.

推荐答案

您应该设置码头在表单中的控件的属性。

You should set the Anchor and Dock properties on the controls in the forms.

属性控制控件的哪些边缘绑定或捆绑到它的形成相应的边缘。
例如,如果您设置,和其父底部的控件的底部边缘之间的距离不会改变,因此,在您调整窗体控件将下移。
如果设置顶部|底部,控制将调整为垂直调整你的形式。

The Anchor property controls which edges of a control are "bound" or "tied" to the corresponding edges of its form.
For example, if you set Anchor to Bottom, the distance between the control's bottom edge and the bottom of its parent will not change, so the control will move down as you resize the form.
If you set Anchor to Top | Bottom, the control will resize vertically as you resize the form.

要进行控制调整的形式,将来四面,或者设置码头填写

To make a control resize with the form, set the Anchor to all four sides, or set Dock to Fill.

这篇关于做最好的办法的WinForms调整大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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