Menu Items

Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio


Jump to: navigation, search
Exam Prep. Guides
70-505 Study Guide
70-526 Study Guide

1. Forms Controls

2. Integrating Data
3. Printing/Reporting
4. Enhancing Usability
5. Asynchronous Prog.
6. Forms Controls
7. Configure/Deploy

edit

Menus usually contain multiple "items". Each item is identified by a short text string, such as "File" or "Exit". When you see a menu in an application such as notepad, there are some items that are always visible. These are called "top-level" items, which can be selected with either the mouse or keyboard shortcuts (if available). When you select a "top-level" item, usually a sub-menu or "drop-down menu" containing more items is displayed.

Each menu item is created using the ToolStripMenuItem class.


Inheritance hierarchy

System.Object 
  System.MarshalByRefObject 
    System.ComponentModel.Component 
      System.Windows.Forms.ToolStripItem (abstract)
        System.Windows.Forms.ToolStripDropDownItem 
          System.Windows.Forms.ToolStripMenuItem


ToolStripMenuItem

The ToolStripMenuItem class represents a menu within a MenuStrip or ContextMenuStrip. It can also represent a submenu of another ToolStripMenuItem object. ToolStripMenuItem objects are viewed by the user, whereas a MenuStrip or ContextMenuStrip object simply establishes a container where menu items appear.

Useful properties

  • Checked - Gets or sets whether a checkmark appears next to the text of the menu item.
  • CheckState - Gets or sets a three-state value for the menu item, based on the CheckState enumeration. This is similar to Checked, but allows an indeterminate setting when the checked or unchecked state cannot be determined.
  • Enabled (overridden from ToolStripItem) - Gets or sets whether the menu item is enabled. A disabled menu is displayed in a grayed-out state and cannot be selected or display any child menu items.
  • Overflow (overridden from ToolStripItem) - Gets or sets how the menu item interacts with an overflow button, based on the ToolStripItemOverflow enumeration.
  • ShortcutKeyDisplayString Gets or sets the string to display as the shortcut for the menu. If this is blank, the actual shortcut key setting is shown.
  • ShortcutKeys - Gets or sets the shortcut keys for this menu item, using the Keys enumeration values.
  • ShowShortcutKeys - Gets or sets whether to display the ShortcutKeys setting when displaying the menu.

Personal tools