This is because every time you delete an item from Items, the ListView must find that item ( going through the list for this ) and update the CheckedItems collection (which repeats all the other items again), so the complexity is O ^ 2.
The easiest way is to cache SelectedIndices and use listItem.Items.RemoveAt ():
var selectedIndices = listView.SelectedIndices.Cast<int>().Reverse().ToList(); listView.BeginUpdate(); foreach (var index in selectedIndices) { listView.Items.RemoveAt(index); } listView.EndUpdate();
If you do not want to use the Cast <> extension method, you can replace the first line:
List<int> oToDelete = new List<int>(SelectedIndices.Count); foreach (int iX in SelectedIndices) { oToDelete.Add(iX); } oToDelete.Reverse();
source share