Visual Basic Concepts

Using the Frame Control

See Also

Frame controls are used to provide an identifiable grouping for other controls. For example, you can use frame controls to subdivide a form functionally — to separate groups of option button controls.

Figure 7.21   The frame control

In most cases, you will use the frame control passively — to group other controls — and will have no need to respond to its events. You will, however, most likely change its Name, Caption, or Font properties.

For More Information   See "Grouping Options with Option Buttons" in "Forms, Controls, and Menus" for a simple demonstration of using the frame control to group option buttons.

Adding a Frame Control to a Form

When using the frame control to group other controls, first draw the frame control, and then draw the controls inside of it. This enables you to move the frame and the controls it contains together.

Drawing Controls Inside the Frame

To add other controls to the frame, draw them inside the frame. If you draw a control outside the frame, or use the double-click method to add a control to a form, and then try to move it inside the frame control, the control will be on top of the frame and you'll have to move the frame and controls separately.

Figure 7.22   Controls inside a frame

Note   If you have existing controls that you want to group in a frame, you can select all the controls, cut them to the clipboard, select the frame control, and then paste them into the frame control.

Selecting Multiple Controls in a Frame

To select multiple controls in a frame , hold down the CTRL key while using the mouse to draw a box around the controls. When you release the mouse, the controls inside the frame will be selected, as in Figure 7.23.

Figure 7.23   Selecting controls inside a frame