Adding a Shortcut

You can add a shortcut key both at design time and at runtime. You add a shortcut key to a menu item at design time by selecting the menu item within the Menu Designer, selecting the Shortcut property from the Properties window, and choosing one of the values offered in the drop-down list as shown in Figure 11 -8.

j Shortcut

ShowS hortcut

None

Tent

Ins

J

Visible

Del

Fl

F2

F3

F4

F5

F6

F7

FS

FS

F10

J

Figure 11-8: Shortcut keys displayed in the Properties window

Figure 11-8: Shortcut keys displayed in the Properties window

You add a shortcut key to a menu item programmatically simply by setting the menu item's Shortcut property to one of the available values. The following code sets the shortcut key of a menu item to F6:

mnuItemNew.Shortcut = System.Windows.Forms.Shortcut.F6

Was this article helpful?

0 0

Post a comment