Add Controls Dynamically In Flowlayoutpanel


Answer :

For a FlowLayoutPanel, you don't need to specify a .Location since the controls are arranged for you:

Represents a panel that dynamically lays out its contents horizontally or vertically. ... The FlowLayoutPanel control arranges its contents in a horizontal or vertical flow direction. Its contents can be wrapped from one row to the next, or from one column to the next.

Just change "flowLayoutPanel1" to the name of your FlowLayoutPanel:

for (int i = 0; i < 5; i++) {     Button button = new Button();     button.Tag = i;     flowLayoutPanel1.Controls.Add(button); } 

Comments

Popular posts from this blog

Chemistry - Bond Angles In NH3 And NCl3

Are Regular VACUUM ANALYZE Still Recommended Under 9.1?

Change The Font Size Of Visual Studio Solution Explorer