Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FlowLayoutPanel autosize

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.

The Code for creating Buttons

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

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.

like image 332
Piotr Minda Avatar asked Oct 19 '22 09:10

Piotr Minda


1 Answers

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)

More details: FlowLayoutPanel Height bug when using AutoSize

like image 175
Piotr Minda Avatar answered Oct 21 '22 23:10

Piotr Minda