TreeList.ShowTreeListMenu Event
OBSOLETE
You should use the 'PopupMenuShowing' instead
Allows you to customize the default menus for column headers, row and footer summaries, nodes, and the empty area.
Namespace: DevExpress.XtraTreeList
Assembly: DevExpress.XtraTreeList.v22.2.dll
NuGet Package: DevExpress.Win.TreeList
Declaration
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("You should use the 'PopupMenuShowing' instead", false)]
public event TreeListMenuEventHandler ShowTreeListMenu
Event Data
The ShowTreeListMenu event's data class is TreeListMenuEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Allow | Gets or sets if display of the menu is allowed. Inherited from PopupMenuShowingEventArgs. |
HitInfo | Provides access to information about the clicked visual element. Inherited from PopupMenuShowingEventArgs. |
Menu | Gets or sets the control’s popup menu that will be shown. Inherited from PopupMenuShowingEventArgs. |
MenuType | Gets the type of the context menu that is about to be shown. Inherited from PopupMenuShowingEventArgs. |
Point | Gets the position where the menu is to be invoked. Inherited from PopupMenuShowingEventArgs. |
Remarks
Use the TreeList.PopupMenuShowing event instead.
Example
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