If you want your application to provide a set of commands to users, menus offer a convenient and consistent way to group commands and an easy way for users to access them. The menu bar appears immediately below the title bar on the form and contains one or more menu titles. When you click a menu title (such as File), a menu containing a list of menu items appears. Menu items can include commands (such as New and Exit), separator bars, and submenu titles. Each menu item the user sees corresponds to a menu control property you define. Multiple menus can be added to one form.
To add a menu to your form
Note You can also select the MainMenu control and drag it onto your form.
The MainMenu control is inserted onto your form, and the default location for the first item on the menu bar is displayed. Two visual markers (Type Here) appear directly to the right and below to signify the next available editing location.
Note By default, the MainMenu property for the form is set to MainMenu1.
The menu caption is added to your menu, and the default location text box moves to the next menu caption location. Continue typing your menu captions until all your captions are complete.
Forms can have several menu items, such as File/Save and File/SaveAs, that change depending on the state of the application. Menus can be enabled or disabled, checked or unchecked, made visible or hidden using properties for each menu item.
If you want to change the main menu used by a form, you change the menu property for the form to a different menu name, for example, mainMenu2.
You can add access keys to your menu. Access keys provide a way for the user to access the menu using only the keyboard. An access key corresponds to an underlined letter on the menu.
To add access keys to a menu
Shortcut keys add accessibility to your menus. A shortcut key is a keyboard combination, such as CTRL+C for copy, that invokes a particular command.
To add a shortcut key to a menu item
-or-
In the Properties window, click the shortcut property and select a key combination.
To remove a shortcut key
At times, you may want to give users various commands that they can apply to the application. For example, there may be several available toolbars in an application. The user can select which toolbar will be displayed by clicking the toolbar name on the menu, and a check mark appears next to the toolbar name.
To enable check marks on a menu
-or-
In the Properties window, click the checked property.
To move a menu
The menu caption moves and snaps to place. Other menu captions that are affected by this change are moved as appropriate.
Note Moving top-level menu captions moves all submenus as well. Submenus are not displayed during the move.
To modify a menu caption
Separator bars are used in menus to add a distinct line between groups of commands.
To create a menu separator bar
A separator bar appears directly below your menu caption.
-or-
Click the right mouse button, and then click Insert Separator on the context menu.
Separator bars can be moved and deleted in the same manner as menu captions.
To delete a menu item from your form
Note To delete the entire menu, select each menu caption and press DELETE, or click the MainMenu control you want to delete and press DELETE.
Confirmation on deletion occurs only on menu captions with submenus.
To edit the name associated with a menu item