Skip to main content

CheckedListBoxItem(Object, Boolean) Constructor

Creates a new CheckedListBoxItem object and instantiates the ListBoxItem.Value and CheckedListBoxItem.CheckState properties.

Namespace: DevExpress.XtraEditors.Controls

Assembly: DevExpress.XtraEditors.v24.2.dll

Declaration

public CheckedListBoxItem(
    object value,
    bool isChecked
)

Parameters

Name Type Description
value Object

An object representing the item’s value. This value is assigned to the ListBoxItem.Value property.

isChecked Boolean

true if the item is checked; otherwise, false. This value is assigned to the CheckedListBoxItem.CheckState property.

Remarks

The isChecked parameter specifies whether the created item is in a checked or unchecked state.

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