How to place a label or a button exactly in the mi

2019-03-04 12:20发布

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.

screenshot

1条回答
2楼-- · 2019-03-04 12:42

Design time :

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

enter image description here

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.

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

查看更多
登录 后发表回答