Skip to main content

How to: Show Enumeration's Values in ImageComboBoxEdit Control

  • 2 minutes to read

The following example demonstrates how to add the values of the HorzAlignment enumeration to the ImageComboBoxEdit control. When a specific item is selected from the dropdown, the corresponding alignment is applied to a text editor.

The image below shows the result of executing the code below. In the image, the ‘Center’ item is selected in the ImageComboBoxEdit control and this centers the text within a text editor:

ImageComboBox.AddEnum_ex

using DevExpress.Utils;

// Add the enumerator's values as dropdown items to the ImageComboBoxEdit control.
imageComboBoxEdit1.Properties.Items.AddEnum(typeof(HorzAlignment));

// A SelectedIndexChanged event handler of the ImageComboBoxEdit control.
private void imageComboBoxEdit1_SelectedIndexChanged(object sender, System.EventArgs e) {
   var icBox = sender as ImageComboBoxEdit;
   if(icBox.SelectedIndex > 0) {
      // Get the selected item.
      ImageComboBoxItem item = icBox.SelectedItem as ImageComboBoxItem;
      // Apply the selected alignment to a text editor.
      textEdit1.Properties.Appearance.TextOptions.HAlignment = (HorzAlignment)item.Value;
   }
}