Name

CheckedListBox

Synopsis

This control, derived from ListBox, provides a list of items with a check beside each one, providing an alternative selection mechanism. It extends the base listbox by providing you with two collection accessors: CheckedItemCollection, which returns the set of all the checked items in the list, and CheckedIndexCollection, which returns a set containing the index of each checked item in the list. You can then use the GetItemChecked() and GetItemCheckState() methods to determine the actual check state for the item.

You can support either two- or three-state checkboxes, and ThreeDCheckBoxes, or flat ones. You can also choose whether the item is checked when it is selected, or whether the checkbox itself must be clicked.


public class CheckedListBox : ListBox {

// Public Constructors

   public CheckedListBox();

// Public Instance Properties

   public CheckedIndexCollection CheckedIndices{get; }

   public CheckedItemCollection CheckedItems{get; }

   public bool CheckOnClick{set; get; }

   public override DrawMode DrawMode{set; get; } // overrides ListBox

   public override int ItemHeight{set; get; } // overrides ListBox

   public ObjectCollection Items{get; } // overrides ListBox

   public override SelectionMode SelectionMode{set; get; } // overrides ListBox

   public bool ThreeDCheckBoxes{set; get; }

// Protected Instance Properties

   protected override CreateParams CreateParams{get; } // overrides ListBox

                  // Public Instance Methods

   public bool GetItemChecked(int index); public CheckState ...

Get .NET Windows Forms in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.