BaseCheckedListBoxControl.Items Property
Provides access to the item collection, when the control is not bound to a data source.
Namespace: DevExpress.XtraEditors
Assembly: DevExpress.XtraEditors.v19.1.dll
Declaration
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.
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.
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);
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the Items property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.