本文介绍了如何在表单中心设置FlowLayoutPanel内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我在 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 FlowLayoutPanelSet AutoSize of FlowLayoutPanel to trueSet AutoSizeMode of FlowLayoutPanel to GrowAndShrinkSet Anchor property of FlowLayoutPanel to Top, Bottom 使用单个列和单个 TableLayoutPanel 中的code> Row 。 设置 Dock TableLayoutPanel 的code>属性更改为底部。 Use a single Column and a single Row in TableLayoutPanel.Set Dock property of TableLayoutPanel to Bottom.这样,当您动态添加或删除图像时,所有图像都将显示在表单的底部中心。This way, when you add or remove images dynamically, all images will be shown at bottom center of the form. 这篇关于如何在表单中心设置FlowLayoutPanel内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-26 19:30