$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
DataGridView WinForms Control
Create custom data grid context menus in C# to Data GirdView for Windows Forms applications
Home > WinForms UI Controls > User Manual > Modify Default Context Menu in C#

GridView Default Context Menu Customizing

In this article, we are going to talk about the way of customizing the default Kettic DataGridView context menu in the ContextMenuOpening event handler. To create the custom context menu, we need to initialize the items of custom context menus, and then subscribe for the events that you are going to handle to achieve desired behavior. The following examples will demonstrate how to remove and add context menus items to GridView C#.NET component for Windows Forms application.

Remove Context Menu Items from C#.NET GridView

The DataGridView control allows users easily remove an item from default KetticGridView context menu. To remove an item, we need to make a loop to iterate the e.ContextMenu.Items first, and then we need to check whether the e.ContextMenu.Items[].Text is equal to the text of the menu item that we are going to hide. If the conditions do like this, we can change the value of the Visibility of the menu item as Collapsed. The following are the C# code for deleting context menu items.
C# code for deleting context menu items from GridView C#.NET component in Windows Forms template project

void ketticGridView1_ContextMenuOpening(object sender, Kettic.WinForms.UI.ContextMenuOpeningEventArgs e)
{
for (int i = 0; i < e.ContextMenu.Items.Count; i++)
{
if (e.ContextMenu.Items[i].Text == "Format Cells Conditionally")
{
e.ContextMenu.Items[i].Visibility = Kettic.WinForms.ElementVisibility.Collapsed;
e.ContextMenu.Items[i + 1].Visibility = Kettic.WinForms.ElementVisibility.Collapsed;
}
}
}

Add Context Menu Items to C#.NET GridView

The DataGridView control allows users easily add menu items to the default Kettic DataGridView context menu. To add custom menu items to the default context menu in DataGridView control, we need to create menu item instances in the ContextMenuOpening event handler and add the instances to the e.ContextMenu.Items. The following are the C# code for adding custom context menu items.
C# code for adding custom context menu items to the default context menu in GridView for C# Windows Forms template project

void ketticGridView1_ContextMenuOpening1(object sender, Kettic.WinForms.UI.ContextMenuOpeningEventArgs e)
{
KetticMenuItem customMenuItem = new KetticMenuItem();
customMenuItem.Text = "Add Custom Context Menu";
KetticMenuSeparatorItem separator = new KetticMenuSeparatorItem();
e.ContextMenu.Items.Add(separator);
e.ContextMenu.Items.Add(customMenuItem);
}
UI Controlsfor Windows Forms
.NET WinForms UI Overview.NET WinForms UI Features.NET WinForms UI GuideC# WinForms UI DesignVB.NET WinForms UI Design
WinForms UI Controls