Using Windows Forms Controls

A number of Windows Forms controls are available on the Toolbox when a designer has focus in your solution. If your designer is a Windows Form or a user control, you will find the greatest number of controls available on the Toolbox. However, when a Word document or Excel worksheet has focus in Visual Studio, fewer controls are available than for Windows Forms controls.

The controls are grouped into categories within the Toolbox to make it easier to locate a control. For example, when a Windows Form or user control is the designer (it has the focus), the categories are Common Controls, Containers, Menus and Toolbars, Data, Components, Printing, Dialogs, and General, as shown in Figure 8.7.

Figure 8.7. Windows Forms controls available on a Windows Form

However, when the document is the designer, categories such as Containers, Menus and Toolbars, and Printing do not appear on the toolbar. Figure 8.8 shows the categories of controls available on a document. The Common Controls category is expanded, revealing the most common Windows Forms controls used on a document.

Figure 8.8. Windows Forms controls available on a Word document

One reason that these controls are not available on the toolbar is that it doesn't make sense to use controls for printing or adding menus and toolbars to a document; this functionality already exists within the application (you typically add toolbars to the application rather than to the document). As you saw in the preceding section, you can add CommandBar controls to Word's and Excel's menus and toolbars, so there isn't any reason to add this type of control to a document.

0 0

Post a comment