This is such a basic question, I'm almost embarassed to ask it. How do I loop through seleted rows in a DataGridView and remove the rows?

I've tried this, but it doesn't work. After one row is removed, the index is all screwed up...

iIndex = dgvRecipe.Rows.GetNextRow(-1, DataGridViewElementStates.Selected)
            While iIndex <> -1
                iIndex = dgvRecipe.Rows.GetNextRow(iIndex, DataGridViewElementStates.Selected)
            End While

As jwavila reminded me on another forum...

For iIndex = dgvRecipe.RowCount - 1 To 0 Step -1
Next iIndex

Try this

For Each dr As DataGridViewRow In dtgqueformat.SelectedRows    ' delete selected records
               If (dtgqueformat.Rows.Count > 1) Then
               End If