VB.NET Developer's Guide

Creating and Working with Menus

Menus hold commands grouped by a common topic. Menus make it easy for your users to navigate your application as they see menus they have already used in Windows, such as the File menu. As an added benefit, using a menu to hold commands avoids using precious real estate on your forms. Let s look at creating menus.

Adding Menus to a Form

You can add menus to a form using the MainMenu control. Menus are often added to a form at design time. You can use the new Menu Designer in Visual Basic .NET to add menus to your forms at design time.

Exercise 7.2 Adding a Menu to a Form at Design Time

In this exercise, you will add a File menu with an Exit menu item to a form at design time:

  1. From the File menu, select New Project.
  2. In the Visual Basic Projects list, select the Windows Application template, and then click OK.
  3. In the Toolbox, select the Win Forms tab, and then double-click the MainMenu control. A menu is added to the form displaying the text Type Here (see Figure 7.11), and the MainMenu control is added to the component tray.


    Figure 7.11: The Menu Designer

  4. In the Menu Designer, click the text Type Here to select the menu, and then type &File (see Figure 7.12).


    Figure 7.12: The File Menu

  5. Click the area below the

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: NVRAM
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.