Adding and Modifying a Menu

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

  1. On the Toolbox, under the WFC tab, double-click the MainMenu control.

Note   You can also highlight the MainMenu control on the Toolbox and, holding down the left mouse button, drag the control 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 locations.

Note   By default, the MainMenu property for the form is set to MainMenu1.

  1. Type the name of your first menu caption in the default location text box. (For example, type File to add the File menu item.) 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 may have several menus, such as File/Save and File/SaveAs. You can switch menus by changing the Menu property for the form to a different menu name, for example, mainMenu2.

To add access keys to a menu

  1. Click the menu caption in which you want to add an access key.

  2. Place the mouse cursor immediately before the letter in the caption box that you want to be your access key letter and type an ampersand (&). For example, on the File menu, click File, placing your cursor before the "F" in File and then type an ampersand. You can also edit the caption title through the Text property for the menu item.

To add shortcut (action) keys to a menu item

  1. Click the menu item caption in which you want to add a shortcut key.

  2. Select a function key or key combination in the Shortcut box which is located in the Properties window.

  3. Set the showShort property to true.

To remove a shortcut key

To enable check marks on a menu

To move a menu

Note   Moving top-level menu captions will move all child members, as well. Child members are not displayed during the move.

To modify a menu

To create a menu separator bar

  1. Click the menu caption that is above the location where you want to add a separator bar.

  2. Press the Dash (รป) key and then press ENTER.

    A separator bar appears directly below your menu caption.

    -or-

Separator bars may be moved and deleted in the same manner as regular menu captions.

To delete a menu item from your form

Note   To delete the entire menu, highlight each menu caption and press DELETE, or click the MainMenu1 control and select Delete from the context menu.

Confirmation on deletion only occurs on menu captions with sub-menus.