在DataGrid中,如何判断复选框一列选中了哪个

2024-11-24 20:36:38
推荐回答(1个)
回答1:

private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
int count = dataGridView1.Rows.Count;
for (int i = 0; i < count; i++)
{
DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)dataGridView1.Rows[i].Cells[0];
Boolean flag = Convert.ToBoolean(checkCell.Value);
if (flag == true) //查找被选择的数据行
{
checkCell.Value = false;
}
else
continue;
}
}

}