围绕在.NET(的WinForms)在表单中的控件? [英] Centering controls within a form in .NET (Winforms)?

查看:235
本文介绍了围绕在.NET(的WinForms)在表单中的控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想集中在表单中的固定大小的控制。

I'm trying to center a fixed size control within a form.

出于兴趣,是否有这样做的非白痴呀?我真正想要的是什么类似于文本对齐CSS属性。

Out of interest, is there a non-idiotic way of doing this? What I really want is something analogous to the text-align css property.

目前,我周围的形式的填充属性设置为合适的尺寸和设置的控制,以填补的Dock属性。

At the moment, I'm setting the padding property of the surrounding form to a suitable size and setting the Dock property of the control to fill.

推荐答案

您可以搭配使用的实现这一目标。以上precisely在不使用它们

You could achieve this with the use of anchors. Or more precisely the non use of them.

控制被默认锚定到,这意味着当表单大小将被改变,从表单顶部左侧的距离将保持恒定的形式的左上角。如果你更改了控制锚左下角,那么控制将继续从窗体的底部和左右两侧的距离相等时的形式,如果调整​​。

Controls are anchored by default to the top left of the form which means when the form size will be changed, their distance from the top left side of the form will remain constant. If you change the control anchor to bottom left, then the control will keep the same distance from the bottom and left sides of the form when the form if resized.

关闭锚的方向将继续调整,当集中在该方向上的控制。

Turning off the anchor in a direction will keep the control centered in that direction when resizing.

这篇关于围绕在.NET(的WinForms)在表单中的控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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