Creating a Menu Bar
You can use the Menu Design window You can also write code to make your menu respond dynamically to user preferences or run-time conditions, such as whether a menu command should be unavailable, or whether menu commands should be added or deleted. to create a menu bar that displays the names of menus available to use in the active window.
To create a menu bar
1. Click the form for which you want to create a menu bar.
2. From the Window menu, choose Menu Design (Ctrl+M), or use the toolbar shortcut:
3. In the Caption text box, type the menu item caption as you want it displayed on the menu bar.
To give the user keyboard access to the menu item, type an ampersand (&) before the letter you want to specify as the access key. At run time, this letter is underlined, and the user can access the menu or command by pressing Alt plus the access key.
To create a separator bar in your menu, type a single hyphen (-) in this box.
4. In the Name text box, type a control name that you'll use to refer to the menu item in code. This name can be identical to the caption.
5. Use the left and right arrows to change the level of a menu item (from a higher level to a lower level or vice versa.) You can have up to four levels of submenus.
Use the up and down arrows to change the position of a menu item (up or down in the list box.)
Choose Next to move to the next line and add another item to the menu.
Choose Insert to add a line before the currently selected line.
Choose Delete to delete the currently selected line.
6. Repeat steps 3-5 to add menu items.
7. Choose OK to accept all the changes and apply them to the selected form.
The menu you created is visible at design time, but no events are generated until you write code.
Optional features for custom menus:
In the Index text box, type a number that determines the control's position within the control array .
To assign a shortcut key to a menu item, select a key from the Shortcut drop-down list.
Select the Window List check box if you want the current menu control to include the name of open MDI child forms.
Enter a unique number in the HelpContextID if you plan to provide a context-sensitive Help topic for the current control.
Select the Checked box if you want a small check mark to appear at the left of a menu item to indicate that the control is turned on or to indicate which of several modes is in effect.
Select the Enabled box if you want the menu item to initially respond to events . Clear the box if you want the menu item to be unavailable and appear dimmed on the menu. An initially unavailable item can later be enabled in code.
Select the Visible box if you want the menu item to appear on the menu.
Note For details on the properties, events , and methods that apply to menus, see the Menu topic.
Attaching an Event Procedure to a Form or Control
Creating a Menu Control Array
Specifying Access Keys
Learning Visual Basic:
Chapter 4, "Menus and Dialogs"