Tools for Creating User Forms

When you design a form, you can insert appropriate controls to make it useful. The Toolbox contains standard Visual Basic buttons for all the controls that you can add to a form. It can also contain additional controls that have been installed on your computer. Controls available in the Toolbox are known as ActiveX controls. These controls can respond to specific user actions, such as clicking a control or changing its value. You will learn how to use the Toolbox controls in the remaining sections of this chapter.

Figure 10-9:

The Toolbox displays the controls that can be added to your custom form.

The Microsoft Office Suite offers additional ActiveX controls that can be placed in the Toolbox for quick access. If you have other applications installed on your computer that contain ActiveX controls, you can also place them in the Toolbox.

To add a new ActiveX control to the Toolbox, follow these steps:

1. Right-click the New Page tab in the Toolbox and choose Rename.

2. In the Caption box, type the new name: Extra Controls. In the Control Tip Text box, type Additional ActiveX Controls. Click OK to return to the Toolbox.

3. Right-click anywhere within the new page area and choose Additional Controls from the shortcut menu. If this option is not available, make sure you are right-clicking the page area and not the Extra Controls tab itself.

4. When the Additional Controls dialog box appears, click the check box for each control you want to add. Figure 10-10 shows the Calendar Control highlighted. When you click OK, this control will appear on the Toolbox active page.

SeIectObjects -TeitBox -listed* -

Opt ion Butt on -Frame -TabStrlp -Sc roll Bar -Image -

- Label

- ComboBo* -ChackBoX -ToggleBuuori -CommandButlcn

- MtiltlPage -Spin Butt on -ReEdh

Figure 10-10:

You can add to the Toolbox additional ActiveX controls that are installed on your computer.

Figure 10-10:

You can add to the Toolbox additional ActiveX controls that are installed on your computer.

The standard Visual Basic controls are described in the next few sections. Label

Labels allow you to add text to your form. The label control is often used to add captions, titles, headings, and explanations. You can use the label to assign a title to those controls that don't have the Caption property (such as text boxes, list boxes, scroll bars, and spin buttons). You can define an accelerator (shortcut) key for the label. For example, by pressing Alt and a specified letter, you can activate the control that was added to the form immediately after adding the label control and setting its Accelerator property. To add a title or a keyboard shortcut to an existing control, add a label control and type a letter in its Accelerator property in the Properties window. Next, choose View | Tab Order, and make sure that the name of the label appears before the name of the control that you want to activate with the assigned keyboard shortcut. You will learn how to use the Tab Order dialog box later in this chapter (see Figure 10-14).

0 0

Post a comment