C# DataGridView CheckBox单选兑现

C# DataGridView CheckBox单选实现private void dgvCustomerCellClick(object sender, DataGridViewCellEv

C# DataGridView CheckBox单选实现

 private void dgvCustomerCellClick(object sender, DataGridViewCellEventArgs e)        {            if (e.ColumnIndex == -1 || e.RowIndex == -1) return;            for (int i = 0; i < dgvMaterial.Rows.Count; i++)            {                DataGridViewCheckBoxCell checkcell = (DataGridViewCheckBoxCell)dgvMaterial.Rows[i].Cells[0];                checkcell.Value = false;            }            DataGridViewCheckBoxCell ifcheck = (DataGridViewCheckBoxCell)dgvMaterial.Rows[e.RowIndex].Cells[0];            ifcheck.Value = true;        }