Xceed SmartUI for WinForms v3.6 Documentation
Using the SmartCheckedListBox SmartControl
Welcome to Xceed SmartUI for WinForms v3.6 > Basic Concepts > SmartControls > SmartCheckedListBox > Using the SmartCheckedListBox SmartControl

This topic demonstrates how to use the SmartCheckedListBox SmartControl using both the designer and code. The code is provided in a sequential order and can be cut and pasted into your application step-by-step.

Basic steps

To use the SmartCheckedListBox in your application, the following steps must be performed:

  1. Add the SmartCheckedListBox control to your form.

If you would prefer to add the SmartCheckedListBox SmartControl to your form programmatically, the following code can be used:<

using Xceed.SmartUI;

using Xceed.SmartUI.Controls.CheckedListBox;

SmartCheckedListBox list = new SmartCheckedListBox();

this.Controls.Add( list );
  1. Double click on the New CheckedListBoxItem menu or click on the drop down arrow to add the desired number of CheckedListBoxItem SmartItems.

If you want to add items other than CheckedListBoxItems, you can click on the drop down arrow and select the SmartItem to add.

To add SmartItems programmatically to the SmartCheckedListBox, you can use the following code:

The first four items to be added will be the default item (in this case the CheckedListBoxItem SmartItem is both the default and the only preferred SmartItem), however the last item to be added is a SmartExplorerTaskPane Task SmartItem.

list.Items.Add( "first item" );

list.Items.Add( "second item" );

list.Items.Add( "third item" );

list.Items.Add( "fourth item" );

list.Items.Add( new Xceed.SmartUI.Controls.ExplorerTaskPane.Task( "My Task" ) );
  1. Configure your SmartCheckedListBox.  You can decide if a CheckedListBoxItem SmartItem is checked, enabled or visible and you can change its text,  position within the list, etc. 

In the following code, we will check the first SmartItem (CheckedListBoxItem) and move the last SmartItem (Task) to the first position:

( ( CheckedListBoxItem )list.Items[ 0 ] ).Checked = true;

list.Items[ list.Items.Count - 1 ].Index = 0;

When you run your application, you end up with an XP-style checked listbox quite similar to the ones found throughout Windows:

Things you should consider