如何在表单中心设置FlowLayoutPanel内容 [英] How to set FlowLayoutPanel contents at Center of Form
问题描述
我在 FlowLayoutPanel
中有一些 Button
控件,我想将它们精确地设置在表格
。
在下图中,通过将 FlowLayoutPanel
填充手动设置为400,将 Button
恰好设置在中间
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.
但是当我尝试调整大小或还原时由于手动设置了填充,按钮不再位于中间。
But when I try to resize or restore down the buttons wont at middle anymore because of manually set of padding.
我可以做些什么来设置按钮每当我尝试调整其大小时,将其放在 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.
推荐答案
使用单个单元格 TableLayoutPanel
适用于居中放置内容并自动调整大小 FlowLayoutPanel
您可以实现所需的功能:
Using a single cell TableLayoutPanel
which is suitable for centering the content and an auto-size FlowLayoutPanel
you can achieve what you are looking for:
在控件上执行以下设置:
Perform these settings on the controls:
- 将图像添加到
FlowLayoutPanel
- 设置
AutoSize
的FlowLayoutPanel
到true
- 将
FlowLayoutPanel
的AutoSizeMode
设置为GrowAndShrink
- 将
FlowLayoutPanel
的Anchor
属性设置为顶部,底部
- Add your images to a
FlowLayoutPanel
- Set
AutoSize
ofFlowLayoutPanel
totrue
- Set
AutoSizeMode
ofFlowLayoutPanel
toGrowAndShrink
- Set
Anchor
property ofFlowLayoutPanel
toTop, Bottom
- 使用单个
列
和单个<TableLayoutPanel
中的code> Row 。 - 设置
Dock 将
TableLayoutPanel
的code>属性更改为底部
。
- Use a single
Column
and a singleRow
inTableLayoutPanel
. - Set
Dock
property ofTableLayoutPanel
toBottom
.
这样,当您动态添加或删除图像时,所有图像都将显示在表单的底部中心。
This way, when you add or remove images dynamically, all images will be shown at bottom center of the form.
这篇关于如何在表单中心设置FlowLayoutPanel内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- Set
- 设置