foreach(DataGridViewRow row in this.dataGridView1.Rows){
if(row.Cells[1].Value!=null && Convert.ToBoolean(cell.Cells[1].Value)==true){
this.dataGridView1.Rows.Remove(row);
}
}
其中foreach循环遍历DataGridView每行,并查找单元格控件类型为丛迹DataGridViewCheckBoxColumn
的控件列的值,是true的,从渗拿并DataGridView中敏卜删除。
for (int i = 0; i
if (dataGridView1.Rows[i].Cells["Column1"].EditedFormattedValue.ToString() == "True")
{
this.dataGridView1.Rows.Remove(dataGridView1.SelectedRows[0]);
}
}
这样就OK了
有两种方法:乎槐
1 调用DataGridView的属性,删除行。型派参考:
http://www.cnblogs.com/jxsoft/archive/2011/05/06/2038952.html
2 在复选框选择事件中直接删除DataGridView的数据源卜顷贺中的对应行,然后在重新绑定。