最大化表单时的中心控制 [英] Center Controls when form is Maximized
问题描述
我有一个Windows窗体,该窗体的Panel
大约有六个Label
.有些标签在Panel
的左侧,有些在中间.我的问题是最大化表单时如何使所有控件居中.
I have a windows form that has a Panel
that has about six Label
s. 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.
例如:
如果面板控件是这样的
Label1 Label2
Label3
Label4 Label5
这是表单最大化时要实现的目标
This is what i want to achieve when the form is maximized
Label1 Label2
Label3
Label4 Label5
推荐答案
在设计时,您需要将控件居中,然后转到每个控件的锚定属性,并删除所有锚定(左,右,上,底部).这样可以确保在调整表单大小时将其保留在设计时的位置.
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.
这篇关于最大化表单时的中心控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!