Table of Contents

Class ContextMenu

Namespace
System.Windows.Forms
Assembly
NetEx.Legacy.WinForms.dll

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

RightToLeft

SourceControl

The last control that was acted upon that resulted in this context menu being displayed.

[Browsable(false)]
public Control SourceControl { get; }

Property Value

Control

Methods

OnCollapse(EventArgs)

Fires the collapse event

protected virtual void OnCollapse(EventArgs e)

Parameters

e EventArgs

OnPopup(EventArgs)

Fires the popup event

protected virtual void OnPopup(EventArgs e)

Parameters

e EventArgs

ProcessCmdKey(ref Message, Keys, Control)

protected virtual bool ProcessCmdKey(ref Message msg, Keys keyData, Control control)

Parameters

msg Message
keyData Keys
control Control

Returns

bool

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

control Control
pos Point

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 Control
pos Point
alignment LeftRightAlignment

Events

Collapse

Fires when the context menu collapses.

public event EventHandler Collapse

Event Type

EventHandler

Popup

public event EventHandler Popup

Event Type

EventHandler