C# DataGridView复选框单击三次调用DataGridView.Committedt(),为什么?

C# DataGridView复选框单击三次调用DataGridView.Committedt(),为什么?,c#,winforms,C#,Winforms,请参考我的视频,查看我所说内容的视频捕获:) 我有一个简单的windows应用程序,带有带有复选框列的datagridview。我想检查单元格的选中/取消选中状态,以便在选中单元格时为其着色 我已经使用了CurrentCellDirtyStateChange()和CellValueChange()。。。当我选中一个复选框时,我不明白为什么控件调用DataGrdview.committedit(…)三次 下面是代码Load(),它将用从DB中获取的数据填充datagridview,这很好。但是对于

请参考我的视频,查看我所说内容的视频捕获:)

我有一个简单的windows应用程序,带有带有复选框列的datagridview。我想检查单元格的选中/取消选中状态,以便在选中单元格时为其着色

我已经使用了CurrentCellDirtyStateChange()和CellValueChange()。。。当我选中一个复选框时,我不明白为什么控件调用DataGrdview.committedit(…)三次

下面是代码Load(),它将用从DB中获取的数据填充datagridview,这很好。但是对于committedit(),它在一个简单的复选框中被调用了3次

 private void dgvList_CurrentCellDirtyStateChanged(object sender, EventArgs e)
    {
        //this condition tells the controller that datagridview is filled with rows.
        //else throws a runtime error
        if (isGridReady == true)
        {
            if (dgvList.CurrentCell is DataGridViewCheckBoxCell)
            {
                dgvList.CommitEdit(DataGridViewDataErrorContexts.Commit);
            } 
        }
    }

    private void dgvList_CellValueChanged(object sender, DataGridViewCellEventArgs e)
    {

        if (isGridReady == true)
        {
            Console.WriteLine(dgvList[3, e.RowIndex].Value.ToString());

            if (Convert.ToBoolean(dgvList[3, e.RowIndex].Value) == true)
            {

                dgvList[3, e.RowIndex].Style.BackColor = Color.Yellow;
            }
            else
                dgvList[3, e.RowIndex].Style.BackColor = Color.White;
        }

    }

谢谢

请发布您的代码