Table of Contents

Class ContextMenu

Namespace
Alternet.UI
Assembly
Alternet.UI.Common.dll

The ContextMenu class represents shortcut menus that can be displayed when the user clicks the right mouse button over a control or area of the form.

[ControlCategory("MenusAndToolbars")]
public class ContextMenu : Menu, IBaseObjectWithAttr, IDisposableObject, IComponent, IDisposable, IContextMenuProperties, IMenuProperties, ICollectionObserver<object>, INotifyPropertyChanged, IBaseObjectWithId, IBaseObject
Inheritance
ContextMenu
Implements
Derived

Remarks

Shortcut menus are typically used to combine different menu items from a MainMenu of a form that are useful for the user given the context of the application. For example, you can use a shortcut menu assigned to a TextBox control to provide menu items for changing the font of the text, finding text within the control, or Clipboard features for copying and pasting text. You can also display new MenuItem objects in a shortcut menu that are not located within a MainMenu to provide situation specific commands that are not appropriate for the MainMenu to display.

Constructors

ContextMenu()

Initializes a new instance of the ContextMenu class.

Properties

HasMainMenuInParents

Gets a value indicating whether a MainMenu exists in the parent hierarchy of this menu item.

HasMainMenuParent

Gets a value indicating whether this ContextMenu is attached to the main menu.

IsImmediateChildOfMenuItem

Gets a value indicating whether this object is an immediate child of a MenuItem.

IsShownInHostControl

Gets a value indicating whether the current instance is currently displayed within a host control.

RelatedControl

Gets or sets the control that was the last source of context menu invocation.

Methods

Assign(IMenuProperties)

Copies the properties from the specified IMenuProperties source to the current instance.

DisposeManaged()

Override to dispose managed resources. Here we dispose all used object references.

HostControlInChildren(AbstractControl?)

Determines whether any visible child of the specified control implements the IContextMenuHost interface.

OnClosing(EventArgs)

Called when menu is closing.

OnOpening(CancelEventArgs)

Called when menu is opening.

RaiseClosing(EventArgs, bool)

Raises the Closing event and OnClosing(EventArgs) method.

RaiseOpening(CancelEventArgs, bool)

Raises the Opening event and OnOpening(CancelEventArgs) method.

Show(AbstractControl, PointD?)

Displays the menu at the specified position.

ShowAsDropDown(AbstractControl, Action?, HVDropDownAlignment?)

Shows the context menu as a drop-down menu under the specified control. This method uses native menu via handler.

ShowAtFactory(AbstractControl, PointD?, IMenuFactory?)

Displays the context menu at the specified position using the provided control and menu factory.

ShowAtMouse()

Displays the context menu at the position of the mouse pointer.

ShowInPopup(AbstractControl, Action?, HVDropDownAlignment?)

Displays the context menu in a popup window.

ShowInsideControl(AbstractControl, AbstractControl?, PointD?, Action?, HVDropDownAlignment?)

Displays the context menu inside the specified container at the given position. Uses InnerPopupToolBar as the host control.

ShowInsideControlAligned(AbstractControl?, HVDropDownAlignment?)

Displays the context menu inside the specified container, aligned according to the specified alignment.

Events

Closed

Occurs when the menu is closed. This event is usually raised only for top level menus.

Closing

Occurs when the menu is closing. This event is usually raised only for top level menus.

Opening

Occurs when the menu is opening. This event is usually raised only for top level menus. You can also handle Opened to be notified when a menu item is opened.