We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How to add the ContextMenu to the GridTreeControl?

The GridTreeControl provides support to the ContextMenu interactive feature that is used to show the customizable menu for performing some functions in Grid. Here, Sorting, copy and paste operations are performed using ContextMenu.

In the GridTreeControl, you can show the context menu based on some criteria with the help of QueryContextMenuInfo event. To show the context menu by using the QueryContextMenuInfo event, you need to set the EnableContextMenu to true.

You can refer to the following code example to enable the ContextMenu in the grid.

 

C#

 

By using the QueryContextMenuInfo event, you can get the details about cells like CellValue, CellType, column index, and row index. Based on those values, you can create your own ContextMenu.

In the following code example, ContextMenu for a grid is created based on the row index in the QueryContextMenuInfo event. Refer to the following code example to add the menu items in the ContextMenu based on the rowindex.

 

C#

 

In the QueryContextMenuInfo event, when the row index is 0 (Header row), then the SortColumn menu item is added to the ContextMenu. For the other rows, Copy and Paste menu items are added. Refer to the following code example to perform the operations on clicking the menu items in the ContextMenu by using the Commands and CommandParameter of a menu item.

 

C#

On clicking the menu items, the following operations are performed.

  • Sort Column - Corresponding column is sorted.
  • Copy - Copy the selected node.
  • Paste - Copied node is pasted in the grid.

When you open the ContextMenu in the Header row, then the ContextMenu is displayed as follows.

Figure 1: Menu Item SortColumn added to ContextMenu

When you open the ContextMenu in other rows, then the ContextMenu is displayed as follows:

Figure 2: Copy, Paste Menu Items are added to Context Menu

Sample Link: AddContextMenuIn_GridTreeControl

Article ID: Published Date: Last Revised Date: Platform: Control: .NET Framework: Product Version:
4053 02/16/2015 07/10/2015 WPF GridTreeControl 4.5 12.4.0.24
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.