Reputation: 16690
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?
Upvotes: 7
Views: 22486
Reputation: 1
try this i have used in VB.net
At the time of adding Items in CheckedListBox
use below code :
For i As Integer = 0 To Dt.Rows.Count - 1
CLB_FolderList.Items.Add(Dt.Rows(i)("Source_FolderName").ToString(),True)
Next
Upvotes: 0
Reputation: 5037
private void Form1_Load(object sender, EventArgs e)
{
for (int i = 0; i < checkedListBox.Items.Count; i++)
{
checkedListBox.SetItemChecked(i, true);
}
}
Upvotes: 1
Reputation: 73472
You can do it programmatically after populating the Items
for (int i = 0; i < checkedListBox.Items.Count; i++)
{
checkedListBox.SetItemChecked(i, true);
}
Upvotes: 11