JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Checked List Boxes

Windows forms checked list boxes are derived from standard list boxes, except that they also support a checkbox for each item, as you see in Figure 7.2—that's the CheckedListBoxes example on the CD-ROM.

Figure 7.2: A checked list box control.

As with standard list boxes, you can access the items in a checked list box using the Items property. To check an item, the user has to double-click a checkbox by default, unless you set the CheckOnClick property to True, in which case it only takes one click.

You can handle the checked items with the CheckedItems property and the CheckedIndices property. You also can use the GetItemChecked method to verify if an item is checked. And you can use the ItemCheck event to handle check events, and the SetItemChecked method to check or uncheck items. We'll do all that in this chapter.

Checked list boxes also can support three states with the CheckState enumeration: Checked, Indeterminate, and Unchecked. (Note that you must set the state of Indeterminate in the code because the user interface does not provide a way of doing so.) To use three-state checkboxes, you use the GetItemCheckState and SetItemCheckState methods instead of GetItemChecked and SetItemChecked methods.

Previous Section Next Section

JavaScript Editor Free JavaScript Editor     JavaScript Editor