How to set CheckedListBox items to checked by default

AdamMc331 picture AdamMc331 · Aug 29, 2014 · Viewed 16.7k times · Source

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?

Answer

Sriram Sakthivel picture Sriram Sakthivel · Aug 29, 2014

You can do it programmatically after populating the Items

for (int i = 0; i < checkedListBox.Items.Count; i++)
{
    checkedListBox.SetItemChecked(i, true);
}