Check all item in listview with huge list item?

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

    You need to call BeginUpdate before the loop and EndUpdate after the loop:

    listView1.BeginUpdate();
    foreach (ListViewItem item in listView1.Items)
        item.Checked = true;
    listView1.EndUpdate();
    

    Calling BeginUpdate prevents the control from drawing until the EndUpdate method is called.

提交回复
热议问题