Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

LookUpEditBase.GetSelectedDataRow() Method

When implemented by a class, this method returns a data source row corresponding to the currently selected edit value.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v24.2.dll

NuGet Package: DevExpress.Win.Navigation

#Declaration

public abstract object GetSelectedDataRow()

#Returns

Type Description
Object

An object that represents a data source row corresponding to the currently selected edit value.

#Remarks

This method is implemented by the 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