Skip to content
the poor coder

lookupedit devexpress get specific row

Poor Man
Published
Reading time
2 min read
On this page

How to Get a Specific Row using DevExpress LookupEdit#

If you are working with DevExpress LookupEdit in your project, you might need to get a specific row based on certain criteria. Here is how you can do it:

Method 1: Using the EditValue property#

The EditValue property of the LookupEdit returns the selected value. In order to get a specific row based on a certain value, you can loop through the rows of the lookup edit until you find the row with the desired value.

C#

// Get the LookupEdit control
LookupEdit lookupEdit = new LookupEdit();

// Get the desired value
int desiredValue = 42;

// Loop through the rows of the lookup edit
foreach (DataRowView row in lookupEdit.Properties.DataSource)
{
    // Get the value of the current row
    int currentValue = Convert.ToInt32(row["Value"]);

    // Check if the current row is the desired row
    if (currentValue == desiredValue)
    {
        // Get the data row of the desired row
        DataRow desiredRow = row.Row;

        // Do something with the desired row
        break;
    }
}

Method 2: Using the GetDataSourceRowIndex method#

The LookupEdit control provides a method called GetDataSourceRowIndex which allows you to get the index of a row based on its value.

C#

// Get the LookupEdit control
LookupEdit lookupEdit = new LookupEdit();

// Get the desired value
int desiredValue = 42;

// Get the index of the desired row
int rowIndex = lookupEdit.Properties.GetDataSourceRowIndex("Value", desiredValue);

// Get the data row of the desired row
DataRow desiredRow = ((DataView)lookupEdit.Properties.DataSource)[rowIndex].Row;

// Do something with the desired row

These are the two methods that you can use to get a specific row using DevExpress LookupEdit control. Choose the one that suits your needs and implement it in your project!

Keep going

2023

how to sort an array

How to Sort an Array If you have an array and you want to order its elements in a specific way, you need to use a sorting algorithm. There are several sorting algorithms available, but two of the most commonly used are…

javascript2 min read
2023

jquery mobile or desktop

jQuery Mobile or Desktop? As a web developer, I have had some experience with both jQuery Mobile and jQuery Desktop. Both frameworks have their pros and cons, and which one to use really depends on the specific project…

javascript1 min read
2023

node.js folder structure

Node.js Folder Structure If you are new to Node.js, it can be daunting to create a folder structure that will work for your project. The structure you choose will depend on the size and complexity of your project. Here…

javascript1 min read
ESC