How to remove rows in data grid view where checkbox is checked?

its happening when one row is removed the rows count decrements too so if you put your code in for loop and run it in reverse it would work fine have a look:

for (int i = dataGridView1.Rows.Count -1; i >= 0 ; i--)
{
    if ((bool)dataGridView1.Rows[i].Cells[0].FormattedValue)
    {
        dataGridView1.Rows.RemoveAt(i);
    }
}

You are modifiend a collection while iterating it.

Use a delete list and than remove the rows.


You are modifying a collection while iterating it. Try like this

List<DataGridViewRow> toDelete = new List<DataGridViewRow>();
foreach (DataGridViewRow row in dataGridView1.Rows) {
    if (row.Cells[0].Value == true) {
        toDelete.Add(row);
    }
}
foreach (DataGridViewRow row in toDelete) {
    dataGridView1.Rows.Remove(row);
}