HomeSearch

FlowLayoutPanel Control

This article covers the FlowLayoutPanel control in Windows Forms.
FlowLayoutPanel simplifies how controls are arranged. With FlowLayoutPanel, we have the controls flow like text from left to right, top to bottom, or the opposite directions. No pixel-based positioning is required for these controls.
Add. To get started, please open your Windows Forms program. Now add a FlowLayoutPanel instance to your Form. You can do this by dragging the FlowLayoutPanel from the Toolbox to the Form.

Next: Add some sub-controls by dragging controls such as Button, Label, CheckBox and TextBox to the inner part of the FlowLayoutPanel.

Anchor. It is usually a good idea to anchor your FlowLayoutPanel to other parts of the Form. I typically anchor controls to the top, right, left and bottom of the form to ensure they resize when the window is resized by the user or other code.
FlowDirection. The unique feature of the FlowLayoutPanel is its support for flowing in different directions. The default flow direction is left to right, like English text. The introductory screenshot in this article shows the FlowDirection of TopDown.

Tip: For the FlowDirection property, you can also use RightToLeft and BottomUp values.

AutoScroll. In some programs, the FlowLayoutPanel may end up being too small to show all the controls. In this case, you can set the AutoScroll property to True. The FlowLayoutPanel will display scrollbars when the controls overflow.
Summary. With FlowLayoutPanel we arrange controls. It takes most of the hassle out of arranging controls. Instead of using complex table layouts or pixel layouts, FlowLayoutPanel introduces a graceful flow of controls into your program.
© 2007-2020 Sam Allen. Every person is special and unique. Send bug reports to info@dotnetperls.com.
Home
Dot Net Perls