Back to Devexpress

DataViewBase.ShowGridMenu Event

wpf-devexpress-dot-xpf-dot-grid-dot-dataviewbase-35cf917e.md

latest5.8 KB
Original Source

DataViewBase.ShowGridMenu Event

Enables you to customize the context menu.

Namespace : DevExpress.Xpf.Grid

Assembly : DevExpress.Xpf.Grid.v25.2.Core.dll

NuGet Package : DevExpress.Wpf.Grid.Core

Declaration

csharp
public event GridMenuEventHandler ShowGridMenu
vb
Public Event ShowGridMenu As GridMenuEventHandler

Event Data

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

PropertyDescription
CustomizationsProvides access to a collection of customizations of the grid menu, customized using this event handler.
HandledGets or sets a value that indicates the present state of the event handling for a routed event as it travels the route. Inherited from RoutedEventArgs.
ItemsGets the menu items contained within the context menu.
MenuInfoGets information about the context menu.
MenuTypeGets the context menu’s type.
OriginalSourceGets the original reporting source as determined by pure hit testing, before any possible Source adjustment by a parent class. Inherited from RoutedEventArgs.
RoutedEventGets or sets the RoutedEvent associated with this RoutedEventArgs instance. Inherited from RoutedEventArgs.
SourceGets the View that raised the event.
TargetElementGets the UI element for which the context menu is shown.

The event data class exposes the following methods:

MethodDescription
InvokeEventHandler(Delegate, Object)When overridden in a derived class, provides a way to invoke event handlers in a type-specific way, which can increase efficiency over the base implementation. Inherited from RoutedEventArgs.
OnSetSource(Object)When overridden in a derived class, provides a notification callback entry point whenever the value of the Source property of an instance changes. Inherited from RoutedEventArgs.

Remarks

The GridControl‘s pop-up menus allow users to manage data (apply grouping and sorting, display summaries, and so on) and customize the View (show and hide its UI elements). All these context menus can be customized.

For information on how you can customize context menus, see Context Menus.

Example

The following example removes an item from the Total Summary panel‘s context menu:

Handle the ShowGridMenu event.

xaml
<dxg:TableView ShowGridMenu="ShowGridMenu" />
csharp
void ShowGridMenu(object sender, GridMenuEventArgs e) {
    if (e.MenuType == GridMenuType.TotalSummary) {
        e.Customizations.Add(new RemoveAction { ElementName = DefaultSummaryMenuItemNames.Customize });
    }
}
vb
Sub ShowGridMenu(sender As Object, e As GridMenuEventArgs)
    If e.MenuType = GridMenuType.TotalSummary Then
        e.Customizations.Add(New RemoveAction() With {.ElementName = DefaultSummaryMenuItemNames.Customize})
    End If
End Sub

See Also

DataViewBase Class

DataViewBase Members

DevExpress.Xpf.Grid Namespace