System.Windows.Forms.Menu Class

Represents the base functionality for all menus. Although System.Windows.Forms.ToolStripDropDown and System.Windows.Forms.ToolStripDropDownMenu replace and add functionality to the System.Windows.Forms.Menu control of previous versions, System.Windows.Forms.Menu is retained for both backward compatibility and future use if you choose.

See Also: Menu Members


[System.ComponentModel.ToolboxItemFilter("System.Windows.Forms", System.ComponentModel.ToolboxItemFilterType.Allow)]
public abstract class Menu : System.ComponentModel.Component


This class is the base class for the System.Windows.Forms.MainMenu, System.Windows.Forms.MenuItem, and System.Windows.Forms.ContextMenu classes. You cannot create an instance of this class. The menus for an application consist of System.Windows.Forms.MenuItem objects. These can contain other System.Windows.Forms.MenuItem objects, representing submenu items. The System.Windows.Forms.MenuItem objects can be stored in a System.Windows.Forms.MainMenu for display as an entire menu structure for a form or a System.Windows.Forms.ContextMenu that is used to display shortcut menus. This class provides functionality that is common for all the menu classes.

Unlike many base classes, the System.Windows.Forms.Menu class uses its derived classes to define many of its properties. If you are using your menu in a multiple-document interface (MDI) application, you can use the Menu.MdiListItem property to specify a System.Windows.Forms.MenuItem that displays a list of open MDI child forms in your application. The Menu.MenuItems property contains a list of System.Windows.Forms.MenuItem objects stored in the menu class. For a System.Windows.Forms.MainMenu or System.Windows.Forms.ContextMenu, this property contains all the System.Windows.Forms.MenuItem objects that are displayed. For a System.Windows.Forms.MenuItem, the Menu.MenuItems property represents the submenu items associated with it.

In addition to the properties that are provided for all the derived menu classes, the System.Windows.Forms.Menu class also provides methods, such as Menu.CloneMenu(Menu) and Menu.MergeMenu(Menu), that enable you to create new menus from existing menus, and also merge two menu structures together.

The System.Windows.Forms.Menu class also defines the nested class System.Windows.Forms.Menu.MenuItemCollection. This class defines the collection of System.Windows.Forms.MenuItem objects used by the Menu.MenuItems property. You can use the methods of the System.Windows.Forms.Menu.MenuItemCollection class to add and remove menu items from a System.Windows.Forms.MainMenu, System.Windows.Forms.ContextMenu, or System.Windows.Forms.MenuItem.


Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 1.0.5000.0,