Class MenuItem
public class MenuItem : Menu, IComponent, IDisposable
- Inheritance
-
MenuItem
- Implements
- Inherited Members
Constructors
MenuItem()
Initializes a MenuItem with a blank caption.
public MenuItem()
MenuItem(string)
Initializes a new instance of the MenuItem class with a specified caption for the menu item.
public MenuItem(string text)
Parameters
text
string
MenuItem(string, EventHandler)
Initializes a new instance of the class with a specified caption and event handler for the menu item.
public MenuItem(string text, EventHandler onClick)
Parameters
text
stringonClick
EventHandler
MenuItem(string, EventHandler, Shortcut)
Initializes a new instance of the class with a specified caption, event handler, and associated shorcut key for the menu item.
public MenuItem(string text, EventHandler onClick, Shortcut shortcut)
Parameters
text
stringonClick
EventHandlershortcut
Shortcut
MenuItem(string, MenuItem[])
Initializes a new instance of the class with a specified caption and an array of submenu items defined for the menu item.
public MenuItem(string text, MenuItem[] items)
Parameters
MenuItem(MenuMerge, int, Shortcut, string, EventHandler, EventHandler, EventHandler, MenuItem[])
Initializes a new instance of the class with a specified caption, defined event-handlers for the Click, Select and Popup events, a shortcut key, a merge type, and order specified for the menu item.
public MenuItem(MenuMerge mergeType, int mergeOrder, Shortcut shortcut, string text, EventHandler onClick, EventHandler onPopup, EventHandler onSelect, MenuItem[] items)
Parameters
mergeType
MenuMergemergeOrder
intshortcut
Shortcuttext
stringonClick
EventHandleronPopup
EventHandleronSelect
EventHandleritems
MenuItem[]
Properties
BarBreak
Gets or sets a value indicating whether the item is placed on a new line (for a menu item added to a MainMenu object) or in a new column (for a submenu or menu displayed in a ContextMenu).
[Browsable(false)]
public bool BarBreak { get; set; }
Property Value
Break
Gets or sets a value indicating whether the item is placed on a new line (for a menu item added to a MainMenu object) or in a new column (for a submenu or menu displayed in a ContextMenu).
[Browsable(false)]
public bool Break { get; set; }
Property Value
Checked
Gets or sets a value indicating whether a checkmark appears beside the text of the menu item.
public bool Checked { get; set; }
Property Value
DefaultItem
Gets or sets a value indicating whether the menu item is the default.
public bool DefaultItem { get; set; }
Property Value
Enabled
Gets or sets a value indicating whether the menu item is enabled.
public bool Enabled { get; set; }
Property Value
Index
Gets or sets the menu item's position in its parent menu.
[Browsable(false)]
public int Index { get; set; }
Property Value
IsParent
Gets a value indicating whether the menu item contains child menu items.
[Browsable(false)]
public override bool IsParent { get; }
Property Value
MdiList
Gets or sets a value indicating whether the menu item will be populated with a list of the MDI child windows that are displayed within the associated form.
public bool MdiList { get; set; }
Property Value
MenuID
Gets the Windows identifier for this menu item.
protected int MenuID { get; }
Property Value
MergeOrder
Gets or sets the relative position the menu item when its menu is merged with another.
public int MergeOrder { get; set; }
Property Value
MergeType
Gets or sets a value that indicates the behavior of this menu item when its menu is merged with another.
public MenuMerge MergeType { get; set; }
Property Value
Mnemonic
Retrieves the hotkey mnemonic that is associated with this menu item. The mnemonic is the first character after an ampersand symbol in the menu's text that is not itself an ampersand symbol. If no such mnemonic is defined this will return zero.
[Browsable(false)]
public char Mnemonic { get; }
Property Value
OwnerDraw
Gets or sets a value indicating whether code that you provide draws the menu item or Windows draws the menu item.
public bool OwnerDraw { get; set; }
Property Value
Parent
Gets the menu in which this menu item appears.
[Browsable(false)]
public Menu Parent { get; }
Property Value
RadioCheck
Gets or sets a value that indicates whether the menu item, if checked, displays a radio-button mark instead of a check mark.
public bool RadioCheck { get; set; }
Property Value
Shortcut
Gets or sets the shortcut key associated with the menu item.
public Shortcut Shortcut { get; set; }
Property Value
ShowShortcut
Gets or sets a value that indicates whether the shortcut key that is associated with the menu item is displayed next to the menu item caption.
public bool ShowShortcut { get; set; }
Property Value
Text
Gets or sets the text of the menu item.
public string Text { get; set; }
Property Value
Visible
Gets or sets a value that indicates whether the menu item is visible on its parent menu.
public bool Visible { get; set; }
Property Value
Methods
CloneMenu()
Creates and returns an identical copy of this menu item.
public virtual MenuItem CloneMenu()
Returns
CloneMenu(MenuItem)
Creates a copy of the specified menu item.
protected void CloneMenu(MenuItem itemSrc)
Parameters
itemSrc
MenuItem
Dispose(bool)
Disposes the MenuItem.
protected override void Dispose(bool disposing)
Parameters
disposing
bool
MergeMenu()
Merges this menu item with another menu item and returns the resulting merged MenuItem.
public virtual MenuItem MergeMenu()
Returns
MergeMenu(MenuItem)
Merges another menu item with this menu item.
public void MergeMenu(MenuItem itemSrc)
Parameters
itemSrc
MenuItem
OnClick(EventArgs)
Raises the Click event.
protected virtual void OnClick(EventArgs e)
Parameters
OnDrawItem(DrawItemEventArgs)
Raises the DrawItem event.
protected virtual void OnDrawItem(DrawItemEventArgs e)
Parameters
OnInitMenuPopup(EventArgs)
protected virtual void OnInitMenuPopup(EventArgs e)
Parameters
OnMeasureItem(MeasureItemEventArgs)
Raises the MeasureItem event.
protected virtual void OnMeasureItem(MeasureItemEventArgs e)
Parameters
OnPopup(EventArgs)
Raises the Popup event.
protected virtual void OnPopup(EventArgs e)
Parameters
OnSelect(EventArgs)
Raises the Select event.
protected virtual void OnSelect(EventArgs e)
Parameters
PerformClick()
Generates a Click event for the MenuItem, simulating a click by a user.
public void PerformClick()
PerformSelect()
Raises the Select event for this menu item.
public virtual void PerformSelect()
ToString()
Returns a string representation for this control.
public override string ToString()
Returns
Events
Click
Occurs when the menu item is clicked or selected using a shortcut key defined for the menu item.
public event EventHandler Click
Event Type
DrawItem
Occurs when when the property of a menu item is set to true and a request is made to draw the menu item.
public event DrawItemEventHandler DrawItem
Event Type
MeasureItem
Occurs when when the menu needs to know the size of a menu item before drawing it.
public event MeasureItemEventHandler MeasureItem
Event Type
Popup
Occurs before a menu item's list of menu items is displayed.
public event EventHandler Popup
Event Type
Select
Occurs when the user hovers their mouse over a menu item or selects it with the keyboard but has not activated it.
public event EventHandler Select