Center Controls when form is Maximized

冷暖自知 提交于 2019-12-24 00:08:38

问题


I have a windows form that has a Panel that has about six Labels. Some of the labels are on the left on the Panel and some at the center. My question is that how do i make all the controls centered when the form is maximized.

For Example:

If the panel controls are like this

Label1                   Label2
           Label3
   Label4             Label5

This is what i want to achieve when the form is maximized

                          Label1                   Label2
                                      Label3
                             Label4             Label5

回答1:


At design time you need to center your controls and then go to the anchoring property of each control and remove any anchoring(Left,Right,Top,Bottom) they have. This will ensure that when form is resized they remain at their design time position.




回答2:


use Anchor property of each control



来源:https://stackoverflow.com/questions/17908217/center-controls-when-form-is-maximized

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!