CheckedListBox.SetItemCheckState Method (Int32, CheckState)


Sets the check state of the item at the specified index.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

member SetItemCheckState : 
        index:int *
        value:CheckState -> unit


Type: System.Int32

The index of the item to set the state for.

Type: System.Windows.Forms.CheckState

One of the CheckState values.

Exception Condition

The index specified is less than zero.


The index is greater than or equal to the count of items in the list.


The value is not one of the CheckState values.

The SetItemCheckState method raises the ItemCheck event.

Items whose CheckState is set to Indeterminate appear with a check mark in the check box, but the box is grayed to indicate the indeterminate status of the checked item.

The following example enumerates the items in the CheckedListBox and checks every other item in the list. The example demonstrates using the SetItemCheckState and SetItemChecked methods to set the check state of an item. For every other item that is to be checked, SetItemCheckState is called to set the CheckState to Indeterminate, while SetItemChecked is called on the other item to set the checked state to Checked.

The example also demonstrates using the Items property to get the CheckedListBox.ObjectCollection to get the Count of items.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top