Check all item in listview with huge list item?

前端 未结 6 995
情书的邮戳
情书的邮戳 2021-01-25 06:19

I want to check about 3000 item in listview. This is a bit of code :

foreach (ListViewItem item in this.lvItem.Items)
{
    item.Checked = !item.Ch         


        
6条回答
  •  野性不改
    2021-01-25 07:19

    I also don't think it's wise to expect a user to click 3000 items. But something I did recently, when adding the items, knowing that there would never be many and by default they should be checked, is check the items before adding them to the list.

    Something like this:

    foreach (Recipient recipient in recipients)
    {
        var item = new ListViewItem(recipient.FirstName + " " + recipient.LastName);
        item.Tag = recipient;
        item.Checked = true;
        lvRicipients.Items.Add(item);
    }
    

提交回复
热议问题