FlowLayoutPanel自动调整大小

FlowLayoutPanel自动调整大小

本文介绍了FlowLayoutPanel自动调整大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在父容器中有流程布局面板停靠点(填充).父容器DockStyle设置为Top.另外,我将两个流容器的FlowDirection属性设置为LeftToRight,将两个容器的AutoSize属性设置为True.流布局面板的主要功能是保持动态添加的按钮.

I have flow layout panel dock (Fill) in parent container. The Parent container DockStyle is set to Top. Also I set the FlowDirection property to LeftToRight for flow layout panel and the AutoSize property to True for both containers. The main function of flow layout panel is to keep dynamically added buttons.

创建按钮的代码

Button productButton = new Button();
productButton.AutoSize = true;
productButton.AutoEllipsis = false;
productButtonPanel.Controls.Add(productButton);

有足够的空间将10-12个按钮排成一行,并且FlowLayoutPanel的效果很好.它将所有新按钮保持在一行中.问题是,即使我不需要多余的空间(新按钮行"),每次我添加新的按钮时,FlowLayoutPanel都会(垂直)调整大小.

There is enough space to keep 10-12 buttons in one line and the FlowLayoutPanel is doing great. It keeps all new buttons in one line.The problem is that the FlowLayoutPanel resizes (vertically) every time I add new Button even when the extra space ("New button line") is not necessary.

推荐答案

最后,我解决了这个问题. Flow Layout Panel是否停靠在Table Layout Panel中?似乎表布局面板"正在讨论对子流程布局面板的自动化进行控制.此问题的解决方法是:

Finally i solved the problem. Flow Layout Panel was docked in Table Layout Panel ?It seems that Table Layout Panel is talking control over autosizing of child Flow Layout Panel.The workaround of this problem is:

Table Layout Panel (autosize = true)
    Panel (autosize = true, Dock=Fill)
        Table Layout Panel  (autosize = true, Dock=Fill)

更多详细信息:使用AutoSize时的FlowLayoutPanel高度错误

这篇关于FlowLayoutPanel自动调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 01:58