Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

How to: Create and Populate CheckedListBoxControl at Runtime

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);