Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set CheckedListBox items to checked by default

Is there an option in Visual Studio to set all items in a CheckedListBox to checked by default? By this I mean I would like all items to be checked upon start up, and the user can unselect items as needed.

If not, is my only option to set all items to checked programatically inside the constructor?

like image 529
AdamMc331 Avatar asked Aug 29 '14 14:08

AdamMc331


2 Answers

You can do it programmatically after populating the Items

for (int i = 0; i < checkedListBox.Items.Count; i++)
{
    checkedListBox.SetItemChecked(i, true);
}
like image 106
Sriram Sakthivel Avatar answered Nov 14 '22 14:11

Sriram Sakthivel


 private void Form1_Load(object sender, EventArgs e)
    {
       for (int i = 0; i < checkedListBox.Items.Count; i++)
       {
         checkedListBox.SetItemChecked(i, true);
       }  

    }
like image 1
Rafik Bari Avatar answered Nov 14 '22 16:11

Rafik Bari