在DataGrid中,如何判断复选框一列选中了哪个
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;
}
}
}
{
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;
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询