mercredi 6 février 2019

Is there any way instead use of for loop to Checked all items from listview?

I am using listview and One different checkbox in windows form application.Now when I checked that checkbox then all Items of listview would be checked. It is working well but now I have more then 500 items So Now Whenever I checked checkbox then It is working but it is taking more time and also UI will stuck or show not responding message.

I am working on visual studio 2017 with .Net 4.5.

  public void checkBox_SelectAll_Click(object sender, EventArgs e)
  {
   if(checkBox_SelectAll.checked)
   {
    for(int i=0;i<listview1.Items.Count;i++)
    {
     listview1.Items[i].Checked=true;
    }
   }
   else
   {
    for(int i=0;i<listview1.Items.Count;i++)
    {
     listview1.Items[i].Checked=false;
    }
   }

  }

I want that My application would not go in not responding status while I click CheckBox.




Aucun commentaire:

Enregistrer un commentaire