This is such a basic question, I'm almost emvbarassed 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...
I've tried this, but it doesn't work. After one row is removed, the index is all screwed up...
Code:
iIndex = dgvRecipe.Rows.GetNextRow(-1, DataGridViewElementStates.Selected)
While iIndex <> -1
dgvRecipe.Rows.RemoveAt(iIndex)
iIndex = dgvRecipe.Rows.GetNextRow(iIndex, DataGridViewElementStates.Selected)
End While