Articles in this section
Category / Section

How to enable Custom Context Menu in GridDataControl

1 min read

ContextMenu displays a list of menu items added to it and performs the specified action when you click on the menu items. In GridDataControl, you can enable the ContextMenu by setting EnableContextMenu property as ‘True’. The ContextMenu for Headers, Records and GroupCaption area are enabled with default MenuItems. You can customize these context menu items using theContextMenuOptions” property.


GridDataControl contain the following ContextMenu options.


Using Default options we can enable the default context menu items only.


Using Custom context menu options we can create the context menu items based on our requirement.


Using CustomWithDefault option we can add context menu items to the default context menu items.



You can customize the HeaderContextMenuItems, GroupHeaderContextMenuItems and RecordContextMenuItems by adding the new menu items to the collection.

For example, you can create menu items for records like “Add”, ”Remove”,” Update” as shown in the following code sample.


<syncfusion:GridDataControl x:Name="grid"                                         
                            ItemsSource="{Binding GDCSource}"



this.grid.HeaderContextMenuItems = GetHeaderContextMenu();
this.grid.GroupHeaderContextMenuItems = GetGroupHeaderContextMenu();
this.grid.RecordContextMenuItems = GetRecordContextMenu();
public List<MenuItem> GetHeaderContextMenu()
    List<MenuItem> list = new List<MenuItem>();
    list.Add(new MenuItem() { Header = " Header Context Menu 1" });
    list.Add(new MenuItem() { Header = " Header Context Menu 2" });
    list.Add(new MenuItem() { Header = " Header Context Menu 3" });
    return list; 
public List<MenuItem> GetGroupHeaderContextMenu()
    List<MenuItem> list = new List<MenuItem>();
    list.Add(new MenuItem() { Header = " Group Header Context Menu 1" });
    list.Add(new MenuItem() { Header = " Group Header Context Menu 2" });
    list.Add(new MenuItem() { Header = " Group Header Context Menu 3" });
    return list; 
public List<MenuItem> GetRecordContextMenu()
    List<MenuItem> list = new List<MenuItem>();
    list.Add(new MenuItem() { Header = "Add" });
    list.Add(new MenuItem() { Header = "Remove" });
    list.Add(new MenuItem() { Header = "Update" });
    return list; 


The following screenshot illustrates the output for customizing the ContextMenu based on cell value using the QueryContextMenuInfo event in GridDataControl.


D:\Syncfusion\Issues\2014 Volume 2\KB Issues\KB Images\Customization based on cell value.png

Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment