Skip to main content

LookUpEditBase.GetSelectedDataRow() Method

When implemented by a class, returns a data source record that corresponds to the currently selected item.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v25.1.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

public abstract object GetSelectedDataRow()

Returns

Type Description
Object

The data source record that corresponds to the currently selected item.

Remarks

This method is implemented by LookUpEdit and GridLookUpEdit classes.

Example

In the following example, a LookUpEdit control is bound to the Categories table, which contains the CategoryID, CategoryName, Description and Picture fields. The control displays data from the first three fields. When you select a new record in the LookUpEditor (the control’s BaseEdit.EditValueChanged event), a separate PictureEdit control displays this record’s Picture field value.

LookUpEdit-GetSelectedDataRow-example.png

private void simpleButton1_Click(object sender, EventArgs e) {
    // Select a record in the LookUpEdit control
    lookUpEdit1.EditValue = lookUpEdit1.Properties.GetKeyValueByDisplayValue("Condiments");
}

private void lookUpEdit1_EditValueChanged(object sender, EventArgs e) {
    LookUpEdit lookUp = sender as LookUpEdit;
    // Access the currently selected data row
    DataRowView dataRow = lookUp.GetSelectedDataRow() as DataRowView;
    // Assign the row's Picture field value to the PictureEdit control
    if (dataRow != null) {
        ImageConverter imConverter = new ImageConverter();
        pictureEdit1.Image = (Bitmap)imConverter.ConvertFrom(dataRow["Picture"]);
    }
}
See Also