Class ContextMenu
This class is used to put context menus on your form and show them for controls at runtime. It basically acts like a regular Menu control, but can be set for the ContextMenu property that most controls have.
public class ContextMenu : Menu, IComponent, IDisposable
- Inheritance
-
ContextMenu
- Implements
- Inherited Members
Constructors
ContextMenu()
Creates a new ContextMenu object with no items in it by default.
public ContextMenu()
ContextMenu(MenuItem[])
Creates a ContextMenu object with the given MenuItems.
public ContextMenu(MenuItem[] menuItems)
Parameters
menuItems
MenuItem[]
Properties
RightToLeft
This is used for international applications where the language is written from RightToLeft. When this property is true, text alignment and reading order will be from right to left.
public virtual RightToLeft RightToLeft { get; set; }
Property Value
SourceControl
The last control that was acted upon that resulted in this context menu being displayed.
[Browsable(false)]
public Control SourceControl { get; }
Property Value
Methods
OnCollapse(EventArgs)
Fires the collapse event
protected virtual void OnCollapse(EventArgs e)
Parameters
OnPopup(EventArgs)
Fires the popup event
protected virtual void OnPopup(EventArgs e)
Parameters
ProcessCmdKey(ref Message, Keys, Control)
protected virtual bool ProcessCmdKey(ref Message msg, Keys keyData, Control control)
Parameters
Returns
Show(Control, Point)
Displays the context menu at the specified position. This method doesn't return until the menu is dismissed.
public void Show(Control control, Point pos)
Parameters
Show(Control, Point, LeftRightAlignment)
Displays the context menu at the specified position. This method doesn't return until the menu is dismissed.
public void Show(Control control, Point pos, LeftRightAlignment alignment)
Parameters
control
Controlpos
Pointalignment
LeftRightAlignment
Events
Collapse
Fires when the context menu collapses.
public event EventHandler Collapse
Event Type
Popup
public event EventHandler Popup