LayoutControl.PopupMenuShowing Event

Occurs when the Context Menu is about to be displayed.

Namespace: DevExpress.XtraLayout

Assembly: DevExpress.XtraLayout.v20.1.dll

Declaration

[DXCategory("Events")]
public event PopupMenuShowingEventHandler PopupMenuShowing
<DXCategory("Events")>
Public Event PopupMenuShowing As PopupMenuShowingEventHandler

Event Data

The PopupMenuShowing event's data class is PopupMenuShowingEventArgs. The following properties provide information specific to this event:

Property Description
Allow Gets or sets whether the menu is allowed to be displayed.
HitInfo Contains information on the clicked point within the Layout Control.
Menu Gets or sets the menu that is about to be displayed.
Point Gets the point at which the menu is about to be displayed.

Remarks

The PopupMenuShowing event fires when an attempt is made to display the Context Menu. You can handle this event to customize the menu (add new items or remove the existing ones). Menu items in the menu are represented by the DXMenuItem class objects and its descendants.

To prevent the menu from being invoked, set the Allow parameter to false.

Examples

The following example shows how to add custom menu items to the Context Menu via the LayoutControl.PopupMenuShowing event.

Two menu items are added: Save Layout which saves the current layout to a memory buffer; and Restore Layout which restores the previously saved layout. Clicking these items will call the LayoutControl.SetDefaultLayout and LayoutControl.RestoreDefaultLayout methods respectively.

The image below shows the resultant menu:

Ex_ShowContextMenu

using DevExpress.XtraLayout;
using DevExpress.Utils.Menu;

private void layoutControl1_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e) {
   e.Menu.Items.Add(new DXMenuItem("&Save Layout", new EventHandler(SaveLayout)));
   e.Menu.Items.Add(new DXMenuItem("&Restore Layout", new EventHandler(RestoreLayout)));
}

private void SaveLayout(object sender, EventArgs e) {
   layoutControl1.SetDefaultLayout();
}

private void RestoreLayout(object sender, EventArgs e) {
   layoutControl1.RestoreDefaultLayout();
}

Implements

DevExpress.XtraLayout.ILayoutControlOwner.PopupMenuShowing
See Also