CheckedListBox::ObjectCollection Class
Represents the collection of items in a CheckedListBox.
System.Windows.Forms::ListBox::ObjectCollection
System.Windows.Forms::CheckedListBox::ObjectCollection
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
The CheckedListBox::ObjectCollection type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | CheckedListBox::ObjectCollection | Initializes a new instance of the System.Windows.Forms::CheckedListBox::ObjectCollection class. |
| Name | Description | |
|---|---|---|
![]() | Count | Gets the number of items in the collection. (Inherited from ListBox::ObjectCollection.) |
![]() | IsReadOnly | Gets a value indicating whether the collection is read-only. (Inherited from ListBox::ObjectCollection.) |
![]() | Item | Gets or sets the item at the specified index within the collection. (Inherited from ListBox::ObjectCollection.) |
| Name | Description | |
|---|---|---|
![]() | Add(Object) | Adds an item to the list of items for a ListBox. (Inherited from ListBox::ObjectCollection.) |
![]() | Add(Object, Boolean) | Adds an item to the list of items for a CheckedListBox, specifying the object to add and whether it is checked. |
![]() | Add(Object, CheckState) | Adds an item to the list of items for a CheckedListBox, specifying the object to add and the initial checked value. |
![]() | AddRange(ListBox::ObjectCollection) | Adds the items of an existing ListBox::ObjectCollection to the list of items in a ListBox. (Inherited from ListBox::ObjectCollection.) |
![]() | AddRange(array<Object>) | Adds an array of items to the list of items for a ListBox. (Inherited from ListBox::ObjectCollection.) |
![]() | Clear | Removes all items from the collection. (Inherited from ListBox::ObjectCollection.) |
![]() | Contains | Determines whether the specified item is located within the collection. (Inherited from ListBox::ObjectCollection.) |
![]() | CopyTo | Copies the entire collection into an existing array of objects at a specified location within the array. (Inherited from ListBox::ObjectCollection.) |
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetEnumerator | Returns an enumerator to use to iterate through the item collection. (Inherited from ListBox::ObjectCollection.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | IndexOf | Returns the index within the collection of the specified item. (Inherited from ListBox::ObjectCollection.) |
![]() | Insert | Inserts an item into the list box at the specified index. (Inherited from ListBox::ObjectCollection.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | Remove | Removes the specified object from the collection. (Inherited from ListBox::ObjectCollection.) |
![]() | RemoveAt | Infrastructure. Removes the item at the specified index within the collection. (Inherited from ListBox::ObjectCollection.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
| Name | Description | |
|---|---|---|
![]() ![]() | ICollection::CopyTo | Infrastructure. Copies the elements of the collection to an array, starting at a particular array index. (Inherited from ListBox::ObjectCollection.) |
![]() ![]() | ICollection::IsSynchronized | Infrastructure. For a description of this member, see ICollection::IsSynchronized. (Inherited from ListBox::ObjectCollection.) |
![]() ![]() | ICollection::SyncRoot | Infrastructure. For a description of this member, see ICollection::SyncRoot. (Inherited from ListBox::ObjectCollection.) |
![]() ![]() | IList::Add | Infrastructure. Adds an object to the ListBox class. (Inherited from ListBox::ObjectCollection.) |
![]() ![]() | IList::IsFixedSize | Infrastructure. For a description of this member, see IList::IsFixedSize. (Inherited from ListBox::ObjectCollection.) |
The collection is accessed from the parent control, CheckedListBox, by the Items property. To create a collection of objects to display in the CheckedListBox control, you can add or remove the items individually by using the Add and Remove methods.
The following example enumerates the items in the CheckedListBox and checks every other item in the list. The example demonstrates using the Items property to get the CheckedListBox::ObjectCollection to get the Count of items.
The example also 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.
void CheckEveryOther_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ ) { // Cycle through every item and check every other. // Set flag to true to know when this code is being executed. Used in the ItemCheck // event handler. insideCheckEveryOther = true; for ( int i = 0; i < checkedListBox1->Items->Count; i++ ) { // For every other item in the list, set as checked. if ( (i % 2) == 0 ) { // But for each other item that is to be checked, set as being in an // indeterminate checked state. if ( (i % 4) == 0 ) checkedListBox1->SetItemCheckState( i, CheckState::Indeterminate ); else checkedListBox1->SetItemChecked( i, true ); } } insideCheckEveryOther = false; }
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

