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

ComboBoxItem.Value Property

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.v18.2.dll

Declaration

[DefaultValue(null)]
public virtual object Value { get; set; }

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

The following code snippets (auto-collected from DevExpress Examples) contain references to the Value property.

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