I have a few Button
controls in a FlowLayoutPanel
, and I want to set them precisely at middle bottom of Form
. In the image below I set the Button
precisely at middle by setting the FlowLayoutPanel
padding manually by 400 to left.
我在FlowLayoutPanel中有一些Button控件,我想将它们精确地设置在Form的中间底部。在下面的图像中,我通过手动将FlowLayoutPanel填充设置为400,将Button精确地设置在中间位置。
But when I try to resize or restore down the buttons wont at middle anymore because of manually set of padding.
但是当我尝试调整大小或恢复按钮时,由于手动设置填充,不再在中间。
Is there anything that I can do to set the buttons in middle of FlowLayoutPanel
whenever I try to resize it. I'm following the answer base on this post to add and remove buttons dynamically.
每当我尝试调整它的大小时,我可以做什么来设置FlowLayoutPanel中间的按钮。我正在按照这篇文章的答案基础动态添加和删除按钮。
1 个解决方案
#1
4
Perform these settings on the controls:
在控件上执行以下设置:
- Add your images to a
FlowLayoutPanel
- Set
AutoSize
ofFlowLayoutPanel
totrue
- 将FlowLayoutPanel的AutoSize设置为true
- Set
AutoSizeMode
ofFlowLayoutPanel
toGrowAndShrink
- 将FlowLayoutPanel的AutoSizeMode设置为GrowAndShrink
- Set
Anchor
property ofFlowLayoutPanel
toTop, Bottom
- 将FlowLayoutPanel的Anchor属性设置为Top,Bottom
- Set
- 将图像添加到FlowLayoutPanel将FlowLayoutPanel的AutoSize设置为true将FlowLayoutPanel的AutoSizeMode设置为GrowAndShrink将FlowLayoutPanel的Anchor属性设置为Top,Bottom
- Use a
TableLayoutPanel
for hosting theFlowLayoutPanel
- Use a single
Column
and a singleRow
inTableLayoutPanel
. - 在TableLayoutPanel中使用单个列和单个行。
- Set
Dock
property ofTableLayoutPanel
toBottom
. - 将TableLayoutPanel的Dock属性设置为Bottom。
- Use a single
- 使用TableLayoutPanel托管FlowLayoutPanel在TableLayoutPanel中使用单个列和单个行。将TableLayoutPanel的Dock属性设置为Bottom。
This way, when you add or remove images dynamically, all images will be shown at bottom center of the form.
这样,当您动态添加或删除图像时,所有图像都将显示在表单的底部中心。
#1
4
Perform these settings on the controls:
在控件上执行以下设置:
- Add your images to a
FlowLayoutPanel
- Set
AutoSize
ofFlowLayoutPanel
totrue
- 将FlowLayoutPanel的AutoSize设置为true
- Set
AutoSizeMode
ofFlowLayoutPanel
toGrowAndShrink
- 将FlowLayoutPanel的AutoSizeMode设置为GrowAndShrink
- Set
Anchor
property ofFlowLayoutPanel
toTop, Bottom
- 将FlowLayoutPanel的Anchor属性设置为Top,Bottom
- Set
- 将图像添加到FlowLayoutPanel将FlowLayoutPanel的AutoSize设置为true将FlowLayoutPanel的AutoSizeMode设置为GrowAndShrink将FlowLayoutPanel的Anchor属性设置为Top,Bottom
- Use a
TableLayoutPanel
for hosting theFlowLayoutPanel
- Use a single
Column
and a singleRow
inTableLayoutPanel
. - 在TableLayoutPanel中使用单个列和单个行。
- Set
Dock
property ofTableLayoutPanel
toBottom
. - 将TableLayoutPanel的Dock属性设置为Bottom。
- Use a single
- 使用TableLayoutPanel托管FlowLayoutPanel在TableLayoutPanel中使用单个列和单个行。将TableLayoutPanel的Dock属性设置为Bottom。
This way, when you add or remove images dynamically, all images will be shown at bottom center of the form.
这样,当您动态添加或删除图像时,所有图像都将显示在表单的底部中心。