0

我正在尝试在我的 datagridview 上显示一个自定义上下文菜单,它工作正常,除非正在编辑单元格。然后它显示带有复制/剪切/...的默认窗口上下文菜单条

有没有办法覆盖 DataGridViewTextBoxCell contextmenustrip 或禁用它?

Disable DataGridView System ContextMenu的解决方案对我不起作用。

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
4

1 回答 1

0
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
于 2011-09-20T10:19:16.457 回答