What is a good way to select all or not select items in a list without using:
foreach (ListViewItem item in listView1.Items) { item.Selected = true; }
or
foreach (ListViewItem item in listView1.Items) { item.Selected = false; }
I know that the basic common Win32 list control supports the LVM_SETITEMSTATE message , which you can use to set the selected state, and passing -1 as the index will apply to all elements. I would rather not send PInvoking messages to the control that is behind the .NET Listview control (I don't want to be a bad developer and rely on undocumented behavior) when they change it to a fully managed ListView class)
Bump
Pseudo Masochist has a SelectNone case:
ListView1.SelectedItems.Clear();
Now I just need SelectAll code
source share