Name

MenuItem

Synopsis

This Menu class represents the submenus of either a MainMenu, ContextMenu, or other MenuItem object. You can add it to the MenuItems property of any of these classes to create such a submenu.

You can control the appearance of the item with a number of different properties. You can set the Text for the menu item, and it can be Enabled, and made Visible. The BarBreak and Break properties cause the menu item to start a new column in the menu, with and without a dividing line, respectively. Checked determines whether a check mark appears next to item text, and RadioCheck determines whether the check mark appears as a radio button instead of a checkmark. Note that you have to handle the mutual exclusion yourself. You can set a Shortcut key to associate with the item, and ShowShortcut determines whether the key is displayed to the right of the text. You can also find out which Mnemonic character is acting as an Alt key shortcut.

To support MDI applications, you can mark an item as the MdiListItem. The system will automatically create and maintain a child menu for this object with a list of the MDI windows owned by the parent Form.

Also for the benefit of MDI and similar applications, Menu objects allow the merging of their items to meld together menus from disparate sources. To control this, you can specify the MergeOrder of a particular item. This is essentially a numeric priority for the item when merging two submenus with the same name. A low number will appear higher ...

Get .NET Windows Forms in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.