开发者

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

开发者 https://www.devze.com 2023-04-06 01:15 出处:网络
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/...

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

精彩评论

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