C# 怎么判断 DataGridView checkbox是否为全选

如果DataGridView checkbox为全选,就全部撤销为全部选!
2024-11-22 01:49:58
推荐回答(1个)
回答(1):

foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (!row.IsNewRow)
{
if (!Convert.ToBoolean(row.Cells["Column2"].Value)) return;
}
}
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (!row.IsNewRow)
{
row.Cells["Column2"].Value = false;
}
}