How to: Create ListBoxControl at Runtime

The following sample code demonstrates how to initialize and create a new instance of the ListBoxControl class at runtime.


using DevExpress.XtraEditors;
// ...
// Initialize an array of strings
string[] States = {
// Initialize and create an instance of the ListBoxControl class
ListBoxControl listBox = new ListBoxControl();
// Define the parent control
listBox.Parent = this;
// Set the listBox's background color
listBox.BackColor = Color.FromArgb(254, 246, 212);
// Dock to all edges and fill the parent container
listBox.Dock = DockStyle.Fill;
// Add items