PopupMenuShowingEventArgs.HitInfo Property
Provides access to information about the clicked visual element.
Namespace: DevExpress.XtraTreeList
Assembly: DevExpress.XtraTreeList.v24.1.dll
NuGet Packages: DevExpress.Win.Navigation, DevExpress.Win.TreeList
Declaration
Property Value
Type | Description |
---|---|
TreeListHitInfo | An object that contains information about a visual element. |
Remarks
The Tree List shows a context menu when the user right-clicks within the following areas:
- Column Header — the control shows the Column Header Context Menu if the EnableColumnMenu option is enabled. The menu contains commands related to columns: sorting, filtering, etc.
- Node — the control shows the Node Context Menu if the EnableNodeMenu option is enabled. The menu contains commands related to nodes: expand, collapse, create a new node, etc.
- Group Footer, Summary Footer — the control shows the Footer Context Menu if the EnableFooterMenu option is enabled. The menu contains commands related to summaries: sum, min, average, etc.
- Empty Area — the menu invoked with a right-click below the tree list’s nodes. The default empty-area context menu does not contain any commands. Use the PopupMenuShowing event to populate the menu.
The HitInfo
and MenuType event arguments allow you to determine the clicked visual element and the type of the menu that is about to be displayed.
Example
The following code sample uses the the TreeList.PopupMenuShowing event to invoke a custom context menu when a user right-clicks a column header:
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