Articles in this section
Category / Section

How to hide the context menu when you click the header cells in the WinForms GridControl?

1 min read

Hide the context menu

By default, ContextMenu opens when clicking on header cells. However, you can hide the context menu when clicking the header cells in WinForms Grid Control by using contextMenuStripEx1_Opening event.


//Event triggered from Form_load
this.contextMenuStripEx1.Opening += contextMenuStripEx1_Opening;
void contextMenuStripEx1_Opening(object sender, CancelEventArgs e)
    int R_index = this.gridControl1.CurrentCell.RowIndex;
    int C_index = this.gridControl1.CurrentCell.ColIndex;
    if (R_index == 0 || C_index == 0)
        //ContextMenuStrip removed for headers
        e.Cancel = true;
        e.Cancel = false;



'Event triggered from Form_load
AddHandler Me.contextMenuStripEx1.Opening, AddressOf contextMenuStripEx1_Opening 
Private Sub contextMenuStripEx1_Opening(ByVal sender As Object, ByVal e As CancelEventArgs)
    Dim R_index As Integer = Me.gridControl1.CurrentCell.RowIndex
    Dim C_index As Integer = Me.gridControl1.CurrentCell.ColIndex
    If R_index = 0 OrElse C_index = 0 Then
      'ContextMenuStrip removed for headers
       e.Cancel = True
       e.Cancel = False
    End If
End Sub


C#: ContextMenu-C#.

VB: ContextMenu-VB.

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