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

530 Valid Hostname Is Expected When Setting Up IIS 10 For Multiple Sites

C Perror Example

Converting A String To Int In Groovy