Question

I'm trying to show a custom contextmenustrip on my datagridview and it works fine except when the cell is being being edited. Then it shows the default windows contextmenustrip with copy/cut/...

Is there a way to overwrite the DataGridViewTextBoxCell contextmenustrip or disable it?

The solution from Disable DataGridView System ContextMenu does'nt work for me.

Private Sub DataGridView1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DocCostGroupDetsDataGridView.MouseDown
        If e.Button = Windows.Forms.MouseButtons.Right Then
            _CustomContextMenuStrip.fGetContextMenu()
            _CustomContextMenuStrip.Show(DataGridView1, e.Location)
        End If
    End Sub
Was it helpful?

Solution

Private Sub DataGridView1_EditingControlShowing(ByVal sender As System.Object, _
                    ByVal e As DataGridViewEditingControlShowingEventArgs) _
                    Handles DataGridView1.EditingControlShowing
       If TypeOf e.Control Is TextBox Then
          With DirectCast(e.Control, TextBox)
             .ContextMenuStrip = ContextMenuStrip2
          End With
       End If
End Sub
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top