Name

Menu

Synopsis

This System.ComponentModel.Component is the abstract base for ContextMenu, MainMenu, and MenuItem classes. It provides most of the functionality of each of these classes but cannot be instantiated itself.

You can add MenuItem objects to the menu through the MenuItems collection. A MenuItem itself can contain further MenuItem objects, to allow for cascading child menus. You can determine if the menu has any children through the IsParent property.

You can also determine which menu item is a special MdiListItem—an item that will display a list of MDI child forms as a child menu. This is a read-only property—you set it through the MenuItem.MdiList property.

The Menu may be hosted in either a ContextMenu or a MainMenu, and you can determine which through the GetContextMenu() and GetMainMenu() methods.

Finally, there is a MergeMenu() method. This merges two menus together (performed automatically for MDI child menus). There is nothing to stop you from using it for your own menu management, however. It is particularly useful where you have a UI plug-in architecture, where various components provide their own little bit of menu structure that you can merge in to the overall menu hierarchy. To control the merge, specify the MenuItem.MergeOrder and MenuItem.MergeType properties (see MenuItem for more information on this).


public abstract class Menu : System.ComponentModel.Component {

// Protected Constructors

   protected Menu(MenuItem[ ] items);

// Public Static Fields public const ...

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.