Skip to main content
A newer version of this page is available. .

ImageComboBoxItemCollection.AddEnum(Type) Method

Adds new items to the collection that will represent elements of the specified enumeration.

Namespace: DevExpress.XtraEditors.Controls

Assembly: DevExpress.XtraEditors.v19.2.dll

Declaration

public void AddEnum(
    Type enumType
)

Parameters

Name Type Description
enumType Type

A Type object which represents the required enumeration.

Remarks

This method fetches elements from the specified enumeration and creates new items within the collection that will represent these elements. An item’s value and description are set so as to identify the corresponding element. So, when a specific item is selected in the ImageComboBoxEdit control, the editor’s edit value will be set to the corresponding enumeration element.

Example

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;
   }
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the AddEnum(Type) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also