简体   繁体   English

Datagridview事件未触发

[英]Datagridview event not firing

I have a dataGridView and I am trying to fire an event when a cell is clicked.I have tried using the following events with no avail: 我有一个dataGridView ,我试图在单击单元格时触发一个事件。我尝试使用以下事件无济于事:

    private void dataGridView2_CellClick(object sender, DataGridViewCellEventArgs e)
    { 
     //dosomething
    }

    private void dataGridView2_CellMouseClick(object sender, DataGridViewCellEventArgs e)
    { 
     //dosomething 
    }

    private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e)
    { 
     //dosomething 
    }

    private void dataGridView2_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
    { 
     //dosomething 
    }

    private void dataGridView2_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
    { 
     //dosomething 
    }


I made sure the dataGridView 's name matched, but none of these events are firing or showing up in the debugger. 我确保dataGridView的名称匹配,但是这些事件均未在调试器中触发或显示。 Am I missing something? 我想念什么吗?

Select the grid in designer, goto properties, click events button in the properties and double click on the value cell on the right of CellClick event OR Goto designer.cs file and look where all properties of gridview are defined and see if any line like this is present 选择设计器中的网格,转到属性,单击属性中的事件按钮,然后双击CellClick事件或Goto designer.cs文件右侧的值单元格,然后查看gridview所有属性的定义位置,并查看是否有像这样的行存在

gridview.CellClick += new EventHandler(dataGridView2_CellClick); gridview.CellClick + =新的EventHandler(dataGridView2_CellClick);

If it isnt present then add it. 如果不存在,则添加它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM