Back to Devexpress

Standard Context Menus

windowsforms-5686-controls-and-libraries-tree-list-feature-center-context-menus-standard-context-menus.md

latest5.5 KB
Original Source

Standard Context Menus

  • Mar 01, 2024
  • 3 minutes to read

The Tree List control displays default context menus for column headers, nodes, group summary footers, and the total summary footer.

Node Menu

If the TreeList.OptionsMenu.EnableNodeMenu option is enabled, the tree list shows a context menu when a user right-clicks a node.

The context menu contains the following predefined commands:

  • Collapse ( Expand ) – collapses (expands) the clicked node. This command is only shown when the node has children.
  • Full Collapse – collapses all nodes.
  • Full Expand – expands all nodes.

Use the TreeList.OptionsMenu.ShowExpandCollapseItems property to hide these commands.

If the control displays the New Item Row, the context menu also contains the following commands:

  • Add Node – creates a new node at the same level as the clicked node.
  • Add Child Node – creates a new child node for the clicked node.

Use the TreeList.OptionsMenu.ShowAddNodeItems property to hide/show these items regardless of the New Item Row visibility.

Column Header Menu

Users can right-click a column header to invoke this menu. Some items, however, can appear disabled, depending on the column’s settings.

The table below describes this menu’s items.

Menu ItemDescription
Sort AscendingSorts data by the values of a column, in ascending order. The item is disabled if the context menu has been activated by clicking the header panel’s empty space. It is enabled if the clicked column’s TreeListOptionsColumn.AllowSort option is enabled.
Sort DescendingSorts data by the values of a column, in descending order. The item is disabled if the context menu has been activated by clicking the header panel’s empty space. It is enabled if the clicked column’s TreeListOptionsColumn.AllowSort option is enabled.
Column ChooserInvokes the Customization Form.
Best FitChanges the width of a column to fit the contents of its cells (equivalent to calling the TreeListColumn.BestFit method for the column). It is disabled if the context menu has been activated by clicking the header panel’s empty space.
Best Fit (all columns)Changes the width of all columns to fit the contents of their cells (equivalent to calling the TreeList.BestFitColumns method).

Group Summary Menu

Users can right-click a group summary in a group footer to invoke this menu. The menu allows the user to clear or apply a summary.

The table below describes this menu’s items.

Menu ItemDescription
SumCalculates the sum of a column’s values. Available for numeric columns only.
MinReturns the minimum of the column’s values.
MaxReturns the maximum of the column’s values.
CountCalculates the number of rows affected by the group summary.
AverageCalculates the average of the column’s values. Available for numeric columns only.
NoneCancels summary calculations.

Total Summary Menu

Users can right-click a total summary in the summary footer to invoke this menu. The menu allows the user to clear or apply a summary.

The menu contains the same items as the Group Summary Menu plus one additional item:

Menu ItemDescription
All NodesSwitches the calculation of the current summary against all nodes, or only against root-level nodes.

See Also

Control the Availability of Standard Context Menus to Users

Customize Standard Context Menus

Custom Context Menus