The most common and the most widely used container is the form. In an application, a form can be configured to display like a regular dialog box, to become a Single Document Interface (SDI) or to participate in a Multiple Document Interface (MDI) application. As mentioned already, there are two categories of controls: parents and children:
A child window can be a parent of another control. For example, the Standard toolbar of Visual Studio 2010 is the parent of the buttons on it. If you close or hide the toolbar, its children disappear. At the same time, the toolbar is a child of the application's form. If you close the application, the toolbar disappears, along with its own children. In this example, the toolbar is a child of the form but is a parent to its buttons.
The type of container you want to use dictates how you acquire that container and add it to your application. Parent controls are somewhat divided in two broad categories: primary parents and intermediate parents. Once you have spent time with them, you will decide which one and when to use a particular control. The primary type of control parenting you will use is a form. This is used as the platform for other controls, including other containers. Therefore, when you start your application, you first decide on the type of application. If you create a Windows Forms application, it gets automatically equipped with a form on which you can add child controls. When the application executes, it can present its contents to the user:
The second category of parents you will encounter qualify as intermediate. Theses containers cannot be the base of an application as does the form. These parents must be positioned on another parent first, then they can host their own children. An example of such a parent is the property page also called tab control. This control must be hosted by a form or dialog box. Here is an example of a property sheet (dialog box) that hosts three property pages (tab controls) and each property page hosts its own child controls: Another type of intermediary container is the toolbar that is usually used to host various buttons.
|