Displays a ListBox in which a check box is displayed to the left of each item.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
This control presents a list of items that the user can navigate by using the keyboard or the scrollbar on the right side of the control. The user can place a check mark by one or more items and the checked items can be navigated with the CheckedListBox.CheckedItemCollection and CheckedListBox.CheckedIndexCollection.
To add objects to the list at run time, assign an array of object references with the AddRange method. The list then displays the default string value for each object. You can add individual items to the list with the Add method.
The object supports three states through the CheckState enumeration: Checked, Indeterminate, and Unchecked. You must set the state of Indeterminate in the code because the user interface for a does not provide a mechanism to do so.
If UseTabStops is true, the will recognize and expand tab characters in an item's text, creating columns. These tab stops are preset and cannot be changed. To use custom tab stops, set UseTabStops to false, set UseCustomTabOffsets to true, and add the custom values to the CustomTabOffsets collection.
The class supports the following three indexed collections:
All items contained in the control.
Checked items (including items in an indeterminate state), which is a subset of the items contained in the control.
Checked indexes, which is a subset of the indexes into the items collection. These indexes specify items in a checked or indeterminate state.
The following three tables are examples of the three indexed collections that the class supports.
The first table provides an example of the indexed collection of items in the control (all items contained in the control).
The second table provides an example of the indexed collection of the checked items.
The third table provides an example of the indexed collection of indexes of checked items.
Index of Item
The following example illustrates how you can use the methods, properties, and collections of a . This is a complete sample ready to run once you have copied it to your project. You can check and uncheck items, use the text box to add items and once you have clicked the save button, clear the checked items.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.