如何在Form中心设置FlowLayoutPanel内容

时间:2021-03-23 15:52:06

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精确地设置在中间位置。

如何在Form中心设置FlowLayoutPanel内容

But when I try to resize or restore down the buttons wont at middle anymore because of manually set of padding.

但是当我尝试调整大小或恢复按钮时,由于手动设置填充,不再在中间。

如何在Form中心设置FlowLayoutPanel内容

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 of FlowLayoutPanel to true
    • 将FlowLayoutPanel的AutoSize设置为true
    • Set AutoSizeMode of FlowLayoutPanel to GrowAndShrink
    • 将FlowLayoutPanel的AutoSizeMode设置为GrowAndShrink
    • Set Anchor property of FlowLayoutPanel to Top, Bottom
    • 将FlowLayoutPanel的Anchor属性设置为Top,Bottom
  • 将图像添加到FlowLayoutPanel将FlowLayoutPanel的AutoSize设置为true将FlowLayoutPanel的AutoSizeMode设置为GrowAndShrink将FlowLayoutPanel的Anchor属性设置为Top,Bottom
  • Use a TableLayoutPanel for hosting the FlowLayoutPanel
    • Use a single Column and a single Row in TableLayoutPanel.
    • 在TableLayoutPanel中使用单个列和单个行。
    • Set Dock property of TableLayoutPanel to Bottom.
    • 将TableLayoutPanel的Dock属性设置为Bottom。
  • 使用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 of FlowLayoutPanel to true
    • 将FlowLayoutPanel的AutoSize设置为true
    • Set AutoSizeMode of FlowLayoutPanel to GrowAndShrink
    • 将FlowLayoutPanel的AutoSizeMode设置为GrowAndShrink
    • Set Anchor property of FlowLayoutPanel to Top, Bottom
    • 将FlowLayoutPanel的Anchor属性设置为Top,Bottom
  • 将图像添加到FlowLayoutPanel将FlowLayoutPanel的AutoSize设置为true将FlowLayoutPanel的AutoSizeMode设置为GrowAndShrink将FlowLayoutPanel的Anchor属性设置为Top,Bottom
  • Use a TableLayoutPanel for hosting the FlowLayoutPanel
    • Use a single Column and a single Row in TableLayoutPanel.
    • 在TableLayoutPanel中使用单个列和单个行。
    • Set Dock property of TableLayoutPanel to Bottom.
    • 将TableLayoutPanel的Dock属性设置为Bottom。
  • 使用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.

这样,当您动态添加或删除图像时,所有图像都将显示在表单的底部中心。