如何将标签或按钮准确地放置在表单的中间? [英] How to place a label or a button exactly in the middle of the Form?

查看:603
本文介绍了如何将标签或按钮准确地放置在表单的中间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找不到工具或属性来将标签或按钮准确地放置在表单的中间.例如,在X轴上. VS 2015.

I can't find tools or properties to place a label or a button exactly in the middle of the Form. For example, on the X axis. VS 2015.

推荐答案

设计时间:

在VisualStudio2010中,我有以下两个按钮可在水平和垂直方向居中:

In my VisualStudio2010 I have these 2 buttons to center horizontally and vertically:

它位于工具栏布局"中.如果不是,您可以通过单击右侧的小按钮来添加它们.它也在格式"菜单中.

Its located in the toolbar "Layout". If it isn't, you can add them by clicking the small button to the right. It is also in the Format menu.

要保持在运行时的中心:请关闭所有锚定.

To keep centered at Runtime: Turn off all anchoring.

注意:只要不改变大小,这将使控件保持在其相对位置.如果确实如此,就像倾向于自动调整大小Labels一样,您将必须对Resize事件进行编码.示例是此处

Note:This will keep the control at its relative position as long as it doesn't change it Size. If it does, like autosize Labels are prone to, you will have to code the Resize event. Examples are here

这篇关于如何将标签或按钮准确地放置在表单的中间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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