Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Expand]Controls and Libraries
 [Collapse]Common Features
  [Expand]Data Binding Common Concepts
  [Expand]Data Source Wizard
  [Expand]Expressions
  [Expand]Behaviors
  [Expand]Application Appearance
  [Expand]Filtering UI Context
  [Expand]High DPI Support
  [Expand]Scaffolding Wizard
  [Expand]Formatting Values
   HTML Text Formatting
  [Collapse]Menus
    How to: Add DXButtonGroupItem to DXPopupMenu and Display Menu as RibbonMiniToolbar
    How to: Add DXEditMenuItem to DXPopupMenu and Display Menu as Toolbar
    How to: Display DXPopupMenu as a Regular Menu, Popup Bar or RibbonMiniToolbar
    How to: Display DXPopupMenu as a Regular Menu, Popup Bar or RibbonMiniToolbar
    How to: Implement Custom Menu in XtraGrid Control
  [Expand]Tooltip Management
  [Expand]Saving and Restoring Layouts
   Clipboard - Copy Data and Formatting
   Version Compatibility: Default Property Values
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

How to: Implement Custom Menu in XtraGrid Control

The following example demonstrates how to implement a custom menu in the XtraGrid control. A menu that is created is displayed when a row in a grid's view is right-clicked. It contains a submenu with a single "Delete Row" item, and a check menu item ("Merging Enabled"). The resultant menu, painted using the Money Twins skin, is shown below:

When a grid's view is right-clicked, the GridView.PopupMenuShowing event is generated. Its Menu parameter specifies the menu which is about to be invoked, and it's possible to customize it as necessary. Note that the XtraGrid doesn't display any default menu when a row is right-clicked. The PopupMenuShowing event, however, still fires in this case and its Menu parameter refers to an empty menu. So, you can use this property to add custom menu items.

In this example three menu items are created and added to the menu:
  • the "Rows" submenu which displays the "Delete Row" menu item. A submenu is represented by the DXSubMenuItem class.
  • the "Delete Row" item, represented by the DXMenuItem class. Clicking on this item deletes the clicked row.
  • the "Merging Enabled" check item, represented by the DXMenuCheckItem class. Clicking on this item triggers the GridOptionsView.AllowCellMerge option, which specifies whether the cell merging feature is enabled

How would you rate this topic?​​​​​​​