9.11. Lay Out Controls Automatically

Problem

You have a large set of controls on a form and you want them arranged automatically.

Solution

Use the FlowLayoutPanel container to dynamically arrange the controls using a horizontal or vertical flow, or use the TableLayoutPanel container to dynamically arrange the controls in a grid.

How It Works

The FlowLayoutPanel and TableLayoutPanel containers simplify the design-time and runtime layout of the controls they contain. At both design time and runtime, as you add controls to one of these panels, the panel's logic determines where the control should be positioned, so you do not need to determine the exact location.

With the FlowLayoutPanel container, the FlowDirection and WrapContents properties determine ...

Get Visual Basic 2008 Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.