Skip to main content

ComboBoxEdit.SelectedItem Property

Specifies the editor’s value.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v24.1.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

[Browsable(false)]
public virtual object SelectedItem { get; set; }

Property Value

Type Description
Object

The editor’s value.

Remarks

When you select an item from the dropdown, a corresponding object from the item collection is automatically assigned to SelectedItem. In addition, entering a value in the edit box changes the SelectedItem.

The SelectedItem property matches the value of the ComboBoxEdit.EditValue property. The difference between them is that you can set ComboBoxEdit.EditValue to any object, while SelectedItem can be set only to an element of the RepositoryItemComboBox.Items collection.

The ComboBoxEdit.SelectedIndex property returns the index of the SelectedItem value in the RepositoryItemComboBox.Items collection. This allows you to know whether the current editor’s value is from the dropdown list or arbitrary data.

Note: to ensure proper functionality of the editor, items in the RepositoryItemComboBox.Items collection must be unique objects.

The code sample below illustrates how to use a combo box to specify the data source for a grid.

xmlDataSet = new System.Data.DataSet("XML DataSet");
xmlDataSet.ReadXml(@".\\transportation.xml");
comboBoxEdit1.Properties.Items.AddRange(new string[] { "Drivers", "Vehicles", "Products" });

private void comboBoxEdit1_SelectedIndexChanged(object sender, EventArgs e)
{
    var combo = sender as ComboBoxEdit;
    gridControl1.DataSource = xmlDataSet.Tables[combo.SelectedItem.ToString()];

}

The following code snippets (auto-collected from DevExpress Examples) contain references to the SelectedItem 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