Check all item in listview with huge list item?

前端 未结 6 867
情书的邮戳
情书的邮戳 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:06

    Will something like this work for you? ...when checked, add the items to a Dictionary ...when unchecked, remove from the Dictionary. Not tested code but wondering if you could do something like this:

    Dictionary Dic = listView.Items 
        .Cast() 
        .ToDictionary(x => x.Text, x => x.SubItems[0].Checked); 
    

    You asked how to better go about it. What I am saying is on your Check Event you will want to add items to your list view. I doubt that a user will actually check all 3000, so change your code to decide how you would want to handle checked items, the example that I have given you uses Lambda expression. If not familiar, then please alter your question to reflect what it is that you actually need and/or want...

提交回复
热议问题