To change the Checkstate of an item in a checkedlistbox control in C# or VB.NET you can use the SetItemCheckState method of the checkedlistbox control.

Sample C#

private void ChangeCheckStateForAllCheckBoxes(bool check) {
    for (int i = 0; i <= (checkedListBox1.Items.Count - 1); i++) {
        if (check)
        {
            checkedListBox1.SetItemCheckState(i, CheckState.Checked);
        }
        else
        {
            checkedListBox1.SetItemCheckState(i, CheckState.Unchecked);
        }
    }  
}

Sample VB.NET

Private Sub ChangeCheckStateForAllCheckBoxes(check As Boolean)
	For i As Integer = 0 To (checkedListBox1.Items.Count - 1)
		If check Then
			checkedListBox1.SetItemCheckState(i, CheckState.Checked)
		Else
			checkedListBox1.SetItemCheckState(i, CheckState.Unchecked)
		End If
	Next
End Sub

for more informations see CheckedListBox.ObjectCollection Class, CheckedListBox.SetItemChecked Method

One thought on “How to change Checkstate of an item in a checkedlistbox control in C# or VB.NET”

Leave a Reply