Let's now add a menu and toolbar to the form. In VB 2005, you can create professional looking Windows applications, complete with menus and toolbars that look like those used with Microsoft Office applications.
In the Menus & Toolbars tab in Toolbox, shown in Figure 1-4, locate and then drag and drop the
ToolStripContainer control onto the form. The
ToolStripContainer control allows other controls (such as the
ToolStrip control) to anchor in the four positions available (left, right, top, and bottom).
ToolStripContainer Tasks menu, click on the "Dock Fill in Form" link (see Figure 1-5) to dock the
ToolStripContainer control onto the form. This will cause the
ToolStripContainer control to fill up the entire form and automatically resize itself when the form is resized.
Now you'll add the application menu. Double-click on the
MenuStrip control in the Toolbox to add it to the form. The
MenuStrip control displays a standard list of drop-down menus at the top of a window. In the
MenuStrip Tasks menu, click on the Insert Standard Items link to add a list of commonly used menu items to the control (see Figure 1-6).
Your form should now look like the one shown in Figure 1-7.
Now you'll add a toolbar to Form1. Select the
MenuStrip control that you have just added by single-clicking on it. In the Toolbox, double click on the
ToolStrip control (or drag and drop it) to add it to the form. This will add the
ToolStrip control to the top of the
ToolStripContainer control, thereby making it moveable. You use the
ToolStrip control to display buttons for tasks users will commonly want to perform. Initially, the toolbar is blank. To add common toolbar items, click on the Insert Standard Items link in the
ToolStrip Tasks menus. Your form should now look like Figure 1-8.
To test the application, press F5. You will now be able to drag the
ToolStrip control and anchor it in one of the four positions (see Figure 1-9).