ComboBoxItem.Value Property
In This Article
Gets or sets the item value. This value is assigned to the editor’s edit value when users select the item.
Namespace: DevExpress.XtraEditors.Controls
Assembly: DevExpress.XtraEditors.v24.1.dll
NuGet Package: DevExpress.Win.Navigation
#Declaration
#Property Value
Type | Default | Description |
---|---|---|
Object | null | The item value. |
#Remarks
When you create items for an ImageComboBoxEdit editor, assign a unique value to each item through its Value property. For a ComboBoxEdit editor, there is no need to create ComboBoxItem object instances, as you may assign values directly to an editor:
CheckedComboBoxEdit comboBox = new CheckedComboBoxEdit();
comboBox.Properties.Items.Add("Value 1");
comboBox.Properties.Items.AddRange(new object[] {"Value 2","Value 3" });
The code sample below illustrates how to create an Image Combo Box with 3 values.
ImageComboBoxEdit imageComboBox = new ImageComboBoxEdit();
imageComboBox.Bounds = new Rectangle(220, 10, 120, 20);
ImageCollection comboBoxImages = new ImageCollection();
comboBoxImages.AddImage(Image.FromFile(".\\photo1.png"));
comboBoxImages.AddImage(Image.FromFile(".\\photo2.png"));
comboBoxImages.AddImage(Image.FromFile(".\\photo3.png"));
imageComboBox.Properties.LargeImages = comboBoxImages;
for (int i = 0; i < comboBoxImages.Images.Count; i++)
imageComboBox.Properties.Items.Add(new ImageComboBoxItem { Value = i+1, ImageIndex = i, Description = string.Format("Photo {0}",(i+1).ToString()) });
imageComboBox.SelectedIndexChanged += (o, e) =>
{
ImageComboBoxEdit edit = o as ImageComboBoxEdit;
XtraMessageBox.Show(string.Format("You have selected photo {0}",edit.EditValue.ToString()));
};
this.Controls.Add(imageComboBox);
See Also