User Forms Versus Windows Forms

When you use VBA to create an Office solution, you can design a user interface to display a dialog box. To do so, you add a UserForm to your project and then add controls to the UserForm. These controls are

Vba Windows Forms
Figure 4.7. A UserForm in VBA that contains all the default ActiveX controls

referred to as ActiveX controls. Whenever the UserForm has focus, the Toolbox, which contains all the default controls, becomes visible. Figure 4.7 shows a UserForm that contains all the default ActiveX controls.

When you use VSTO to create an Office solution, you can design the user interface by designing a Windows Form that can be displayed as a window, as a dialog box, or on a user control that appears in the document or Document Actions task pane. The Toolbox in Visual Studio displays all the Windows Forms controls that are available for a Windows Form. Figure 4.8 shows a Windows Form with all the controls that are displayed on the UserForm in Figure 4.7. The Toolbox in Figure 4.8 also shows some of the controls that can be added to the Windows Form.

Notice that some of the controls that are available for a UserForm are not available on a Windows Form—for example, the Toggle control, the Spin control, and the MultiPage control. Many additional Windows

Figure 4.8. A Windows Form in VSTO with Toolbox displaying a portion of the available controls

Forms controls that appear on the Toolbox are not displayed in Figure 4.8. These controls are described in Chapter 8.

+1 0

Post a comment