Deleting rows from a DataGridView control.
Posted on 2008-10-14
I'm trying to figure out the best way to delete rows from my dataGridView control.
The dataGridView contains 2 colums: 1 - CheckBox; 2 - String
I would like to be able to delete the rows based on whether the checkbox is selected or not.
My code looks like this:
// Loop through and remove the rows where the value is checked
foreach (DataGridViewRow dgvExistingRow in this.dataGridViewFileNames.Rows)
This isn't quite working right. If all the rows are to be removed (they are all checked), then only N-1 rows are removed,
where N is the number of rows in the row collection.
I know this should be relatively straightforward, but I'm just not seeing it.
Thanks in advance,