how to select all listview items ?
There is already an accepted answer for this but I use something similar to this:
lv.BeginUpdate();
List<ListViewItem> items = (from i in lv.Items).ToList;
items.ForEach(i => i.Selected == true);
lv.EndUpdate();
It seems to run much faster if there's several thousand items. Also, since we're using BeginUpdate()
and EndUpdate()
, the ListView control doesn't update after selecting each item.
Just pass your listview and checkstate to the function.
public void CheckAllItems(ListView lvw, bool check)
{
lvw.Items.OfType<ListViewItem>().ToList().ForEach(item => item.Checked = check);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With