Skip to main content

BaseCheckedListBoxControl.Items Property

Access the item collection, when the control is not bound to a data source.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v23.2.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

[DXCategory("Data")]
public CheckedListBoxItemCollection Items { get; }

Property Value

Type Description
CheckedListBoxItemCollection

A CheckedListBoxItemCollection object representing the items collection displayed within the CheckedListBoxControl.

Remarks

In unbound mode, use the Items property to get the item collection stored by the checked list box. You can add, remove and access individual items using index notation. Each item in the collection is represented by the CheckedListBoxItem object.

You can also access the checked indexes and items collections via the BaseCheckedListBoxControl.CheckedIndices and BaseCheckedListBoxControl.CheckedItems properties respectively.

To improve the control’s performance while performing multiple changes on the item collection, use the ListBoxItemCollection.BeginUpdate/ListBoxItemCollection.EndUpdate methods.

When the control is bound to a data source via the BaseListBoxControl.DataSource property, the Items collection is always empty. In this instance, to access particular items, use the BaseListBoxControl.GetItem method. To get and set an item’s check state, use the BaseCheckedListBoxControl.GetItemChecked, BaseCheckedListBoxControl.GetItemCheckState, BaseCheckedListBoxControl.SetItemChecked and BaseCheckedListBoxControl.SetItemCheckState methods.

Use the ItemCount property to get the number of items in the ListBox control in bound and unbound modes.

Example

The following sample code demonstrates how to create and populate a CheckedListBoxControl at runtime. The image below illustrates the control’s look & feel after sample code execution.

CheckedListBoxControl

using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
// ...
CheckedListBoxItem[] items = {
                                 new CheckedListBoxItem("January", false),
                                 new CheckedListBoxItem("February", false),
                                 new CheckedListBoxItem("March", true),
                                 new CheckedListBoxItem("April", false),
                                 new CheckedListBoxItem("May", false),
                                 new CheckedListBoxItem("June", true),
                                 new CheckedListBoxItem("July", true),
                                 new CheckedListBoxItem("August", false),
                                 new CheckedListBoxItem("September", false),
                                 new CheckedListBoxItem("October", false),
                                 new CheckedListBoxItem("November", false),
                                 new CheckedListBoxItem("December", false)
                              };
private void CreateCheckedListBoxControl(CheckedListBoxItem[] items){
   CheckedListBoxControl checkedListBoxControl = new CheckedListBoxControl();
   Controls.Add(checkedListBoxControl);
   checkedListBoxControl.Left = 20;
   checkedListBoxControl.Top = 20;
   checkedListBoxControl.Width = 200;
   checkedListBoxControl.Height = 150;
   checkedListBoxControl.Items.AddRange(items);
}
// ...
CreateCheckedListBoxControl(items);
See Also