ImageComboBoxEdit Class
A combo box editor whose items can display images.
Namespace: DevExpress.XtraEditors
Assembly: DevExpress.XtraEditors.v24.2.dll
Declaration
Remarks
The ImageComboBoxEdit
is a combo box that can display item images.
The editor’s ImageComboBoxEdit.Properties property returns a RepositoryItemImageComboBox object that allows you to customize the editor’s appearance and behavior.
Tip
The following help topic describes the difference between standalone editors and repository items (in-place editors): Edit Data. Create Cell Editors. Validate User Input.
Create a Standalone ImageComboBoxEdit
The following code creates a standalone ImageComboBoxEdit
, populates the Items collection, and specifies the edit value.
Note
In this example, svgImageCollection1
was created and populated at design time.
ImageComboBoxEdit ImageComboBox1;
public Form1() {
ImageComboBox1 = new ImageComboBoxEdit();
ImageComboBox1.Location = new System.Drawing.Point(0, 0);
// Assign an image collection.
ImageComboBox1.Properties.SmallImages = svgImageCollection1;
// Add items.
ImageComboBox1.Properties.Items.Add("Profile", 0, 0);
ImageComboBox1.Properties.Items.Add("Refresh", 1, 1);
ImageComboBox1.Properties.Items.Add("Settings", 2, 2);
// Set the edit value.
ImageComboBox1.EditValue = 0;
this.Controls.Add(ImageComboBox1);
}
The following screenshot shows the result:
Tip
The ImageComboBoxEdit
control can also display values from an enumeration. See the following help topic for more information and an example: ImageComboBoxItemCollection.AddEnum.
Use an ImageComboBoxEdit in a Container Control
The following code creates a RepositoryItemImageComboBox object, populates the Items collection, and assigns the editor to a Data Grid column’s ColumnEdit property.
Note
In this example, svgImageCollection1
and svgImageCollection2
were created and populated at design time.
RepositoryItemImageComboBox ImageComboBox;
public Form1() {
ImageComboBox = new RepositoryItemImageComboBox();
// Assign image collections.
ImageComboBox.SmallImages = svgImageCollection1;
ImageComboBox.LargeImages = svgImageCollection2;
// Create items.
ImageComboBox.Items.Add("Ms.", "Ms.", 2);
ImageComboBox.Items.Add("Mrs.", "Mrs.", 1);
ImageComboBox.Items.Add("Mr.", "Mr.", 0);
ImageComboBox.Items.Add("Dr.", "Dr.", 3);
// Assign the editor to a Data Grid column.
gridControl1.RepositoryItems.Add(ImageComboBox);
gridView1.Columns["TitleOfCourtesy"].ColumnEdit = ImageComboBox;
}
The following image shows the result:
Edit Value
The ImageComboBoxEdit.EditValue property specifies the editor’s value (the value of the selected item). You can also use the SelectedItem or SelectedIndex property to select an item (these properties are in sync with the EditValue
property). The ImageComboBoxEdit
displays an empty edit box if the item with the specified value/index does not exist in the Items collection.
An EditValue
change triggers EditValueChanging and EditValueChanged events.
Note
Item values must be unique within the Items
collection.
The default item value is null
. Set values when you create ImageComboBoxEdit
items. Otherwise, an end user will not be able to select items in the ImageComboBoxEdit
.
Images
The ImageComboBoxEdit
can display small and/or large images. Use the following properties to specify image collections:
If both properties are set, the image combo box editor displays small images in the edit box and large images in the dropdown.
If none of these properties are specified, the ImageComboBoxEdit
displays only item descriptions.
Tip
Read the following help topic for more information: Image Gallery and Context-Dependent Images.