C# DataGridView CellLeave未启动
我有一个问题,datagridview_CellLeave事件没有触发,我在网上搜索了这个问题,但没有找到任何关于它的信息,你能在这方面提供帮助吗?下面是我的代码C# DataGridView CellLeave未启动,c#,datagridview,C#,Datagridview,我有一个问题,datagridview_CellLeave事件没有触发,我在网上搜索了这个问题,但没有找到任何关于它的信息,你能在这方面提供帮助吗?下面是我的代码 /** * dataGridView1_CellLeave() method * Find sum and populate third cell. */ private void dataGridView1_CellLeave(object sender, DataGridVi
/**
* dataGridView1_CellLeave() method
* Find sum and populate third cell.
*/
private void dataGridView1_CellLeave(object sender, DataGridViewCellEventArgs e)
{
Console.Write("Cell Leave entry");
int sum = 0;
if (e.ColumnIndex == 0) //if second cell
{
sum = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[1].Value) *
Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[2].Value);
dataGridView1.Rows[e.RowIndex].Cells[3].Value = sum;
MessageBox.Show("Cell Leave sum: " + sum);
}
} //dataGridView1_CellLeave
您是否在任何地方连接该活动?感谢您的回复,对不起,我是C#和VisualStudio的新手,连接该活动的意义是什么?你是说一个触发它的地方还是什么?Windows事件基本上是一个发布/订阅场景。。。您已经创建了一些希望在用户离开单元格时执行的代码,现在需要订阅dataGridvView1控件的CellLeave事件。在代码中的某个地方,您应该有一行读作dataGridView1.CellLeave+=dataGridView1\u CellLeave(除非您使用的是xaml和路由事件)。非常感谢,这很有帮助…:)干杯,伙计,祝你好运。pluralsight.com是一个非常好的.NET培训网站。:)