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