How to: Show Array of Strings in ListBoxControl

The following sample code initializes the myColors array of strings representing system color names. Then, if no external data source is assigned to the control, the ListBoxControl's item collection is populated with myColors elements.

// Initialize an array of strings representing system colors names
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 an external data source is assigned to the ListBox
if (listBoxControl1.DataSource == null)
   // add items to the ListBox. 
   listBoxControl1.Items.AddRange(myColors);