FlowLayoutPanel panel = new FlowLayoutPanel(); panel.FlowDirection = FlowDirection.TopDown; panel.Controls.Add(new Label() { Text = "First" }); panel.Controls.Add(new Label() { Text = "Second" }); panel.Controls.Add(new Label() { Text = "Third" });
FlowLayoutPanel panel = new FlowLayoutPanel(); panel.FlowDirection = FlowDirection.LeftToRight; panel.Controls.Add(new Button() { Text = "Button 1" }); panel.Controls.Add(new Button() { Text = "Button 2" }); panel.Controls.Add(new Button() { Text = "Button 3" }); // Force layout of panel and child controls panel.PerformLayout();Brief Description: The first example creates a new FlowLayoutPanel, sets the flow direction to top-down, and adds three labels to the panel. The second example creates a new FlowLayoutPanel, sets the flow direction to left-to-right, adds three buttons to the panel, and then forces the panel to perform layout immediately. Both examples show how to use the PerformLayout() method to arrange child controls in a FlowLayoutPanel. Package Library: The System.Windows.Forms namespace belongs to the .NET Framework Class Library, which is a core component of the .NET platform. The FlowLayoutPanel class is defined in the System.Windows.Forms.dll assembly, which provides a set of classes for building Windows Forms applications.