[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
   Reporting
  [Collapse]Data Grid
   [Expand]Getting Started
   [Expand]Implementation Details
   [Expand]Views
   [Expand]Grid View Data Layout
   [Expand]Binding to Data
   [Expand]Master-Detail Data Representation
   [Expand]Data Editing and Validation
   [Expand]Grouping
   [Expand]Filtering and Searching
   [Expand]Sorting
   [Expand]Data Summaries
   [Expand]Paging and Scrolling
   [Expand]Focus, Navigation, Selection
   [Expand]Drag-and-Drop
   [Expand]Conditional Formatting
   [Expand]Appearance Customization
   [Expand]MVVM Enhancements
   [Expand]Printing and Exporting
   [Collapse]End-User Interaction
     Context Menus
     Column Chooser
     Tooltips
   [Expand]Miscellaneous
   [Expand]Performance Improvement
   [Expand]Design-Time Features
   [Expand]Visual Elements
   [Expand]End-User Capabilities
   [Expand]Examples
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Gantt Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Context Menus

The GridControl can display popup menus that enable an end-user to manage data (apply grouping and sorting, display summaries, etc.) and customize a View by showing and hiding its UI elements. All these menus can be customized. For example, you can remove existing menu items and/or add new items.

Expanded Context Menus Overview

Use the GridViewBase.GridMenu property to obtain the context menu currently being displayed within a View.

Menu Type

Description

Availability

Image

Group Panel

This menu is shown when an end-user right-clicks within the Group Panel.

GridViewBase.IsGroupPanelMenuEnabled

Column

This menu is shown when an end-user right-clicks a column header.

DataViewBase.IsColumnMenuEnabled

Row Cell

This menu is shown when an end-user right-clicks a data cell. You should manually create this menu.

For an example, see How to: Display a Context Menu for Data Cells.

DataViewBase.IsRowCellMenuEnabled

Summary

This menu is shown when an end-user right-clicks within the Summary Panel.

DataViewBase.IsTotalSummaryMenuEnabled

Fixed Summary

This menu is shown when an end-user right-clicks within the Fixed Summary Panel.

DataViewBase.IsTotalSummaryMenuEnabled

To obtain the current column, view or grid, use the dxg:GridPopupMenu.GridMenuInfo attached property.

GridControl displays specific context menus in Compact Mode.

Expanded Customizing Context Menus

Change Menu Item Names

When customizing a menu (e.g. removing or moving default items), menu items are referred to by their names. Default menu item names are listed in DefaultColumnMenuItemNames and DefaultSummaryMenuItemNames.

Customize Menu Items in Code

Handle the DataViewBase.ShowGridMenu event to dynamically customize grid menus at runtime.

Add, Move, and Remove Menu Items

A View provides multiple properties that allow you to customize its context menus by adding new menu items or removing existing items. These properties return a BarManagerActionCollection object that provides multiple methods, used to manage menu items contained within a context menu:

Menu Type

Property

Group Panel

GridViewBase.GroupPanelMenuCustomizations

Column

DataViewBase.ColumnMenuCustomizations

Band

TableView.BandMenuCustomizations

Row Cell

DataViewBase.RowCellMenuCustomizations

Summary

DataViewBase.TotalSummaryMenuCustomizations

Group Row

GridViewBase.GroupRowMenuCustomizations

Compact Panel

TableView

TableView.CompactModeFilterElementMenuCustomizations

TableView.CompactModeFilterMergeElementMenuCustomizations

TableView.CompactModeSortElementMenuCustomizations

TreeListView

TreeListView.CompactModeFilterElementMenuCustomizations

TreeListView.CompactModeFilterMergeElementMenuCustomizations

TreeListView.CompactModeSortElementMenuCustomizations

Note

This feature is not available in DXTreeList when Hierarchical Data Templates are used.

Example 1: Add Menu Items

The following example demonstrates how to add a custom menu item to the context menu of a grid column. For this, it is necessary to add a corresponding bar item (e.g. BarCheckItem) to the DataViewBase.ColumnMenuCustomizations collection, and specify different item properties. Also, you can insert this item into a specific position by attaching the BarItemLinkActionBase.ItemLinkIndex property to it.

Example 2: Remove Menu Items

The following example demonstrates how to remove a specific item from the context menu, which is shown for the Total Summary panel. For this, the RemoveBarItemAndLinkAction object is added to the DataViewBase.TotalSummaryMenuCustomizations collection, and the name of the bar item is specified by the corresponding field of the DefaultSummaryMenuItemNames class.

Expanded Examples

Is this topic helpful?​​​​​​​