Disable DataGridView System ContextMenu

后端 未结 1 1964
北荒
北荒 2021-01-14 18:32

Does anyone know how I can disable the System Context Menu when a user right clicks in a DataGridViewTextBoxCell? I have tried to override the WndProc at the DataGridView

相关标签:
1条回答
  • 2021-01-14 19:10

    This worked for me:

       private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
        {
            e.Control.ContextMenu = new ContextMenu();
        }
    

    Just set the ContextMenu property to new (empty) ContextMenu in the EditingControlShowing event of the DataGridView.

    0 讨论(0)
提交回复
热议问题