1
我有ContextMenuStrip,右鍵單擊顯示可供選擇的內容。當單元格不處於編輯模式時,它處於完美狀態,但當它處於編輯模式時,當我單擊鼠標右鍵時,它會顯示窗口菜單(複製,粘貼,刪除,全選...)。所以在我的datagridview的hadnled和CellEndEdit寫有這段代碼:在編輯模式下禁用右鍵單擊數據網格
if (MouseButton == System.Windows.Forms.MouseButtons.Right)
{
MouseEventArgs e3 = new MouseEventArgs(System.Windows.Forms.MouseButtons.Right, 1, Location.X,
Location.Y, 1);
DataGridViewCellMouseEventArgs e2 = new DataGridViewCellMouseEventArgs(e.ColumnIndex,
e.RowIndex, Location.X, Location.Y, e3);
DataGridValues_CellMouseClick(sender, e2);
}
凡MouseButton
爲MouseButtons
。它進入並做了一切,但我得到了2個菜單(我的和窗戶)。所以我需要禁用Windows右鍵菜單。有沒有辦法做到這一點?我認爲DataGridValues_CellMouseClick(sender, e2);
中的代碼並不重要,因爲它正在工作。
我嘗試過了,它似乎並不工作。 – Georgi
它爲我工作。當編輯文本框右鍵單擊它顯示由我分配的contextmenustrip – Sathish
我認爲它應該工作,但它沒有。我會再試一次,也許這是因爲其他事件。我會重播你所做的事。 – Georgi