Skip to main content

Add Custom Menu Items to the Standard Menus

  • 2 minutes to read

Add Custom Menu Items to the Standard Menus

To add custom menu items to the standard context menus, handle the TreeList.PopupMenuShowing. While handling this event, the Menu parameter provides access to the menu, allowing it to be extended.

Regular items in the menu are represented by the DXMenuItem class, while check items are represented by the DXMenuCheckItem class. You can use any of these classes to create custom menu items. When creating a menu item, you need to associate a Click event handler with the item. It will be invoked if an end-user selects the item. If custom information must be passed to the item’s Click event handler, use the DXMenuItem.Tag property.


The following example demonstrates how to add a custom item to a standard context menu and handle the click event for this item. The TreeList.PopupMenuShowing event is handled to add the Clear All item to the summary footer menu. Clicking this item cancels the summary calculations for all Tree List columns.

ContextMenus - CustomItemClick

using DevExpress.Utils.Menu;
using DevExpress.XtraTreeList;
using DevExpress.XtraTreeList.Columns;
private void treeList1_PopupMenuShowing(object sender, DevExpress.XtraTreeList.PopupMenuShowingEventArgs e) {
    TreeList tL = sender as TreeList;
    TreeListHitInfo hitInfo = tL.CalcHitInfo(e.Point);
    if (hitInfo.HitInfoType == HitInfoType.SummaryFooter) {
        DXMenuItem menuItem = new DXMenuItem("Clear All", this.clearAllMenuItemClick);
        menuItem.Tag = hitInfo.Column;

private void clearAllMenuItemClick(object sender, EventArgs e) {
    TreeListColumn clickedColumn = (sender as DXMenuItem).Tag as TreeListColumn;
    if (clickedColumn == null) return;
    TreeList tl = clickedColumn.TreeList;
    foreach (TreeListColumn column in tl.Columns)
        column.SummaryFooter = SummaryItemType.None;