Skip to main content

How to: Show Array of Strings in ListBoxControl

The code below uses an array of strings to populate the Items collection.

// Initialize an array of strings.
string[] myColors = {
                        Color.Black.Name,
                        Color.Blue.Name,
                        Color.Brown.Name,
                        Color.Green.Name,
                        Color.Red.Name,
                        Color.Yellow.Name,
                        Color.Orange.Name
                     };
// Check whether a data source is assigned to the ListBoxControl.
if (listBoxControl1.DataSource == null)
   // Add items to the ListBoxControl.
   listBoxControl1.Items.AddRange(myColors);