CheckedListBox.ObjectCollection Class
TOC
Collapse the table of content
Expand the table of content

CheckedListBox.ObjectCollection Class

 

Represents the collection of items in a CheckedListBox.

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

System.Object
  System.Windows.Forms.ListBox.ObjectCollection
    System.Windows.Forms.CheckedListBox.ObjectCollection

public class ObjectCollection : ListBox.ObjectCollection

NameDescription
System_CAPS_pubmethodCheckedListBox.ObjectCollection(CheckedListBox)

Initializes a new instance of the System.Windows.Forms.CheckedListBox.ObjectCollection class.

NameDescription
System_CAPS_pubpropertyCount

Gets the number of items in the collection.(Inherited from ListBox.ObjectCollection.)

System_CAPS_pubpropertyIsReadOnly

Gets a value indicating whether the collection is read-only.(Inherited from ListBox.ObjectCollection.)

System_CAPS_pubpropertyItem[Int32]

Gets or sets the item at the specified index within the collection.(Inherited from ListBox.ObjectCollection.)

NameDescription
System_CAPS_pubmethodAdd(Object)

Adds an item to the list of items for a ListBox.(Inherited from ListBox.ObjectCollection.)

System_CAPS_pubmethodAdd(Object, Boolean)

Adds an item to the list of items for a CheckedListBox, specifying the object to add and whether it is checked.

System_CAPS_pubmethodAdd(Object, CheckState)

Adds an item to the list of items for a CheckedListBox, specifying the object to add and the initial checked value.

System_CAPS_pubmethodAddRange(Object[])

Adds an array of items to the list of items for a ListBox.(Inherited from ListBox.ObjectCollection.)

System_CAPS_pubmethodAddRange(ListBox.ObjectCollection)

Adds the items of an existing ListBox.ObjectCollection to the list of items in a ListBox.(Inherited from ListBox.ObjectCollection.)

System_CAPS_pubmethodClear()

Removes all items from the collection.(Inherited from ListBox.ObjectCollection.)

System_CAPS_pubmethodContains(Object)

Determines whether the specified item is located within the collection.(Inherited from ListBox.ObjectCollection.)

System_CAPS_pubmethodCopyTo(Object[], Int32)

Copies the entire collection into an existing array of objects at a specified location within the array.(Inherited from ListBox.ObjectCollection.)

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetEnumerator()

Returns an enumerator to use to iterate through the item collection.(Inherited from ListBox.ObjectCollection.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodIndexOf(Object)

Returns the index within the collection of the specified item.(Inherited from ListBox.ObjectCollection.)

System_CAPS_pubmethodInsert(Int32, Object)

Inserts an item into the list box at the specified index.(Inherited from ListBox.ObjectCollection.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodRemove(Object)

Removes the specified object from the collection.(Inherited from ListBox.ObjectCollection.)

System_CAPS_pubmethodRemoveAt(Int32)

This API supports the product infrastructure and is not intended to be used directly from your code. Removes the item at the specified index within the collection.(Inherited from ListBox.ObjectCollection.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodICollection.CopyTo(Array, Int32)

This API supports the product infrastructure and is not intended to be used directly from your code. Copies the elements of the collection to an array, starting at a particular array index.(Inherited from ListBox.ObjectCollection.)

System_CAPS_pubinterfaceSystem_CAPS_privmethodIList.Add(Object)

This API supports the product infrastructure and is not intended to be used directly from your code. Adds an object to the ListBox class.(Inherited from ListBox.ObjectCollection.)

System_CAPS_pubinterfaceSystem_CAPS_privpropertyICollection.IsSynchronized

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see ICollection.IsSynchronized.(Inherited from ListBox.ObjectCollection.)

System_CAPS_pubinterfaceSystem_CAPS_privpropertyICollection.SyncRoot

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see ICollection.SyncRoot.(Inherited from ListBox.ObjectCollection.)

System_CAPS_pubinterfaceSystem_CAPS_privpropertyIList.IsFixedSize

This API supports the product infrastructure and is not intended to be used directly from your code. For a description of this member, see IList.IsFixedSize.(Inherited from ListBox.ObjectCollection.)

NameDescription
System_CAPS_pubmethodAsParallel()

Overloaded. Enables parallelization of a query.(Defined by ParallelEnumerable.)

System_CAPS_pubmethodAsQueryable()

Overloaded. Converts an IEnumerable to an IQueryable.(Defined by Queryable.)

System_CAPS_pubmethodCast<TResult>()

Casts the elements of an IEnumerable to the specified type.(Defined by Enumerable.)

System_CAPS_pubmethodOfType<TResult>()

Filters the elements of an IEnumerable based on a specified type.(Defined by Enumerable.)

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.

private 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;
}

.NET Framework
Available since 1.1

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft