Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make one checkbox make all checboxes checked in Listview C#

I am making quarantine and I have listView for showcase of all viruses, and I added checkbox to listview in Header Column (I don't know if I can add checkbox in header column). I added separate column with checkboxes.

I want that checkbox in header when it's checked that all checkboxes in viewlist items are checked.

I hope somebody can help. Thanks!

like image 852
Vepth Avatar asked Mar 04 '23 16:03

Vepth


1 Answers

Using a Button Click:

private void button1_Click(object sender, EventArgs e)
{ 
   for (int i = 0; i < listView1.Items.Count; i++)
  {
    listView1.Items[i].Checked = true;
  }
}

Clicking on the Column Header you can use the listView1_ColumnClick(object sender, ColumnClickEventArgs e) event.

like image 92
Jeremy Thompson Avatar answered Mar 23 '23 00:03

Jeremy Thompson