DataGridView复选框实现单选功能(二)

时间:2022-01-22 06:17:07

DataGridView复选框实现单选功能(二)

双击DataGridView进入事件

private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
int count = dataGridView1.Rows.Count;
for (int i = ; i < count; i++)
{
DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)dataGridView1.Rows[i].Cells[];
Boolean flag = Convert.ToBoolean(checkCell.Value);
if (flag == true)
{
checkCell.Value = false;
}
else
{
continue;
}
} }