8.4. Container Controls

Several controls, known as container controls, are designed specifically to help you with your form's layout and appearance. Rather than have their own appearance, they hold other controls within their bounds. Once a container houses a set of controls, you no longer need to move the child controls individually, but can instead just move the container. Using a combination of Dock and Anchor values, you can have whole sections of your form's layout automatically redesign themselves at runtime in response to the resizing of the form and the container controls that hold them.

8.4.1. Panel and SplitContainer

The Panel control is used to group components that are associated with each other. When placed on a form, it can be sized and positioned anywhere within the form's design surface. Because it's a container control, clicking within its boundaries will select anything inside it. In order to move it, Visual Studio 2008 places a move icon at the top left corner of the control. Clicking and dragging this icon enables you to reposition the Panel.

The SplitContainer control (shown in Figure 8-12) automatically creates two Panel controls when added to a form (or another container control). It divides the space into two sections, each of which you can control individually. At runtime, users can resize the two spaces by dragging the splitter bar that divides them. SplitContainers can be either vertical (as in Figure 8-12) or horizontal, and they can be contained with ...

Get Professional Visual Studio® 2008 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.