DataGridView CellLeave未触发

时间:2015-11-13 18:38:42

标签: c# datagridview

我有一个问题,即datagridview_CellLeave事件没有被触发,我在网上搜索了这个问题,但我没有找到任何关于它的信息,请你帮忙吗?以下是我的代码。

        /**
     * 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

0 个答案:

没有答案