开发者

vb.net DataGridview show custom ContextMenuStrip on cell that is being edited

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.

Privat开发者_运维百科e 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


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜