1
我正在使用Visual Studio,並嘗試從用戶雙擊DataGridView單元格時獲取信息。我基本上設置CellDoubleClick事件就像任何其他Click事件,但似乎並不奏效。Visual C# - 使用CellDoubleClick事件關聯事件處理程序
代碼:
Form1.cs的
private void dataGridView1_CellDoubleClick(Object sender, DataGridViewCellEventArgs e)
{
System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "ColumnIndex", e.ColumnIndex);
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "RowIndex", e.RowIndex);
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "CellDoubleClick Event");
}
在Form1.Designer.cs相關代碼
this.dataGridView1.CellDoubleClick += new System.EventHandler(this.dataGridView1_CellDoubleClick);
我得到的Form1.Designer代碼一個錯誤,指出,「 'dataGridView1_CellDoubleClick'沒有過載匹配代表'System.EventHandler'。
H我可以得到雙擊正確工作嗎? 謝謝。
好吧,我不是在Visual Studio的非常好,我是那種在我束手無策試圖讓雙擊工作。看完你的評論後,我仔細看了一眼設計師,發現了事件按鈕。現在它可以工作。謝謝。 – Rupert 2010-11-23 02:51:23