Posts

Showing posts with the label Dynamic Controls

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); }