A newer version of this page is available. Switch to the current version.

TreeList.PopupMenuShowing Event

Allows you to customize the default menus for column headers, summary footers and nodes.

Namespace: DevExpress.XtraTreeList

Assembly: DevExpress.XtraTreeList.v19.1.dll


public event PopupMenuShowingEventHandler PopupMenuShowing
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 if display of the menu is allowed.
Menu Gets or sets the control's popup menu that will be shown.
Point Gets the position where the menu is to be invoked.


The TreeList control supports context menus for column headers, summary footers and nodes. By default, the menus for column headers and summary footers are not empty, while the menu for nodes is empty.

Use the PopupMenuShowing event to customize these menus by adding/removing menu items. It's also possible to disable the menus via the event's Allow parameter.

To get the type of the menu, read the e.Menu.MenuType parameter, which is of the TreeListMenuType type.

The TreeList.OptionsMenu property provides options controlling the availability of the context menus for column headers and summary footers.


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", new EventHandler(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;


The following sample code handles the TreeList.PopupMenuShowing event for the following two purposes.

  • Disables the summary footer context menu for the "Department" column.
  • Removes the "Runtime columns customization" item of the column header context menu.
using DevExpress.XtraTreeList;

private void treeList1_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e) {
    TreeList treeList = sender as TreeList;
    TreeListHitInfo hitInfo = treeList.CalcHitInfo(e.Point);

    // prohibiting summary footer menu for the "Department" column
    if (hitInfo.HitInfoType == HitInfoType.SummaryFooter &&
      hitInfo.Column.Caption == "Department")
        e.Allow = false;

    // removing the "Runtime columns customization" item of the column header menu
    if (hitInfo.HitInfoType == HitInfoType.Column) {
        string caption = TreeListLocalizer.Active.GetLocalizedString(GetMenuColumnCustomizationStringId(treeList));
        e.Menu.Items.Remove(e.Menu.Items.FirstOrDefault(x => x.Caption == caption));

private TreeListStringId GetMenuColumnCustomizationStringId(TreeList treeList) {
    if (treeList.OptionsView.ShowBandsMode == DefaultBoolean.True || (treeList.OptionsView.ShowBandsMode == DefaultBoolean.Default && treeList.Bands.Count > 0))
        return TreeListStringId.MenuColumnBandCustomization;
    return TreeListStringId.MenuColumnColumnCustomization;
See Also