Skip to main content

PopupMenuShowingEventArgs Class

Contains data for the TreeList.PopupMenuShowing event.

Namespace: DevExpress.XtraTreeList

Assembly: DevExpress.XtraTreeList.v24.1.dll

NuGet Packages: DevExpress.Win.Navigation, DevExpress.Win.TreeList

Declaration

public class PopupMenuShowingEventArgs :
    BasePopupMenuShowingEventArgs

Example

The following code sample invokes a custom context menu when a user right-clicks a column header:

WinForms TreeList - Custom Column Context Menu

  1. Add a BarManager to the form and create a custom PopupMenu as demonstrated in the following help topic: Popup Menus:

    WinForms Popup Menu Designer

  2. Handle the TreeList.PopupMenuShowing event and call the e.ShowCustomMenu method to display your custom menu instead of the default menu.

void TreeList1_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e) {
    if (e.MenuType == TreeListMenuType.Column) {
        popupMenu_Column.Tag = e.HitInfo;
        popupMenu_Column.MenuCaption = $"{e.HitInfo.Column}";

        e.ShowCustomMenu(popupMenu_Column);
    }
}
TreeListHitInfo GetHitInfo(BarItemLink link) {
    PopupMenu menu = link.LinkedObject as PopupMenu;
    return menu.Tag as TreeListHitInfo;
}
void barButtonItem_Filter_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) {
    TreeListHitInfo info = GetHitInfo(e.Link);
    info.Column.TreeList.ShowFilterEditor(info.Column);
}

void barButtonItem_ColumnChooser_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) {
    TreeListHitInfo info = GetHitInfo(e.Link);
    info.Column.TreeList.ShowCustomization();
}
See Also