TreeList.TreeListMenuItemClick Event
Provides the ability to perform custom handling of a context menu item click.
Namespace: DevExpress.XtraTreeList
Assembly: DevExpress.XtraTreeList.v19.1.dll
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 a value indicating whether a summary footer’s menu item 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 sample code changes the behavior of the Sort Ascending and Sort Descending items of the column header menu. By default, clicking one of these items sorts the data by the values in the associated column without clearing the previously applied sorting. This allows sorting by multiple columns to be implemented.
In the example, the TreeList.TreeListMenuItemClick
event is handled to clear the existing sorting, before the column values are sorted.
using DevExpress.XtraTreeList.Columns;
using DevExpress.XtraTreeList;
//...
private void treeList1_TreeListMenuItemClick(object sender, TreeListMenuItemClickEventArgs e) {
if(e.IsFooter) return;
TreeList tl = (sender as TreeList);
if(e.MenuItem.Caption == "Sort Ascending" || e.MenuItem.Caption == "Sort Descending") {
tl.ClearSorting();
if(e.MenuItem.Caption == "Sort Ascending")
e.Column.SortOrder = SortOrder.Ascending;
else
e.Column.SortOrder = SortOrder.Descending;
e.Handled = true;
}
}