What is the best way to delete multiple items from a listview?
Printable View
What is the best way to delete multiple items from a listview?
to remove the selected items you can do something like this
VB Code:
Dim item As ListViewItem For Each item In ListView1.Items If (item.Selected) Then ListView1.Items.Remove(item) End If Next
I don't think that would work, because if you delete item 0 then the item 1 will became it 0 and so on, so the thing is : you must start deleting from the last item to the 1st one so this kind of error doesn't happen
actually it works just fine. Because it is only removing the selected items...so if you select all the items...it just removes all the items.
Lookin carefully at the code i think it is working because it is a for...each statement.
Try doing it with a for() loop and it will pomp out an error
Thanks guys... this works good.