【发布时间】:2014-10-31 06:17:36
【问题描述】:
我想从动态生成的DataGridView中取消选中所有选中的复选框?
我尝试过如下
for (int i = 0; i < MygridView.Rows.Count; i++)
{
DataGridViewCheckBoxCell cell = (DataGridViewCheckBoxCell)MygridView.Rows[i].Cells[0];
if (cell.Value == cell.TrueValue)
{
// (row.Cells[CheckBoxColumn.Index] as DataGridViewCheckBoxCell).value = false;
Need to unchecked all checked checkboxes
}
}
或者还有其他方法吗?
【问题讨论】:
-
为什么是如果? cell.Value = false 或 = cell.FalseValue 应该这样做.. 或者他们是 TriState?然后离开 if 但使用您准备好的单元格变量..
-
还有什么生成的?但除此之外,您不需要循环和强制转换。
标签: c# winforms checkbox datagridview