public static void ReverseSelections(this ListViewBase listView) { if (listView.SelectedItems.Count == 0) { listView.SelectAll(); return; } if (listView.SelectedItems.Count == listView.Items.Count) { listView.ClearSelections(); return; } var selected = listView.SelectedItems.ToHashSet(); listView.SelectedItems.Clear(); foreach (var item in selected) { if (!selected.Contains(item)) { listView.SelectedItems.Add(item); } } }