Skip to main content

TreeList.TreeListMenuItemClick Event

Provides the ability to perform custom handling of a context menu item click.

Namespace: DevExpress.XtraTreeList

Assembly: DevExpress.XtraTreeList.v24.1.dll

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

Declaration

[DXCategory("Behavior")]
public event TreeListMenuItemClickEventHandler TreeListMenuItemClick

Event Data

The TreeListMenuItemClick event's data class is TreeListMenuItemClickEventArgs. The following properties provide information specific to this event:

Property Description
AutoFilterCondition Returns the clicked Automatic Filtering Row condition.
Column Gets the column against whose header or footer the context menu has been activated.
Handled Gets or sets a value indicating whether default menu item click processing is prohibited.
IsFooter Gets whether an item in the footer summary’s context menu has been clicked.
MenuItem Gets the clicked menu item.
MenuType Gets the type of menu whose item has been clicked.
SummaryFormat Gets or sets the format of summary value displayed for the column.
SummaryType Gets or sets the summary type which is about to be applied to the column.

Remarks

The TreeListMenuItemClick event fires immediately after a context menu item has been clicked and before this click has been processed. It enables you to perform additional processing for a menu item click. For instance, it can be used to apply custom formatting to summary values when summary type is changed via a context menu.

There are three kinds of context menus provided by the TreeList control. Use the TreeList.OptionsMenu property to control the availability of menus to users.

Example

The following code sample changes the behavior of Sort Ascending and Sort Descending items in the column header menu. The default items do not clear the applied sorting. The TreeList.TreeListMenuItemClick event handler clears the existing sorting before the sort operation.

void treeList1_TreeListMenuItemClick(object sender, TreeListMenuItemClickEventArgs e) {
   if (e.MenuItem.Caption == "Sort Ascending" || e.MenuItem.Caption == "Sort Descending") {
         e.Column.TreeList.ClearSorting();
         if (e.MenuItem.Caption == "Sort Ascending")
            e.Column.SortOrder = SortOrder.Ascending;
         else
            e.Column.SortOrder = SortOrder.Descending;
         e.Handled = true;
   }
}
See Also