Menu Items and Ampersands
Someone asked me about this, and though ampersands in menus is as old as VB 1.0 the question comes up because the associated shortcut keys don’t appear underlined by default in some versions of Windows.
Most Windows Forms applications have a menu bar at the top. The menu in my sample application looks like this:
The original Windows Forms layout standards suggested that each primary menu and menu option have an associated shortcut key. That way the user can access the menu options without having to move their hands from the keyboard.
In Visual Studio, you define the shortcut key for a menu or menu option by adding an ampersand (&) in front of the character in the menu option Text property. For example, the Text property of the Help menu above is defined as "&Help". This identifies the H as the keyboard shortcut key. The About menu option is defined as "&About", making the A the shortcut key.
With Windows 7 (and Vista I believe), you don’t see the keyboard shortcut key shown underlined in the menu by default. You have to press the Alt key for underlines to appear. In my example, only the Help menu and menu options have short cut keys.
As you hold down the Alt key, you can press H to open the Help menu, then A to open the About box.
Enjoy!