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

Android - ImageView With Rounded Only One Corner

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

403 Access Denied On Tomcat 8 Manager App Without Prompting For User/password