0
votes

Using Devexpress Xtragird and trying to find row by ItemID column.

GridView activeView = this.DataGridSection.SectionGridControl.MainView as GridView;

1st way:

int rowHandle = activeView .LocateByValue("ItemID", 12345);
            if(rowHandle != DevExpress.XtraGrid.GridControl.InvalidRowHandle)
                activeView .FocusedRowHandle = rowHandle;

2nd way:

        for (int i = 0; i < activeView.DataRowCount; i++)
        {
            DataRow dr = activeView.GetDataRow(i);
            if (Convert.ToInt32(dr["ItemID"]) == SelectedItemIDForEdit)
            {
                activeView.SelectRow(i);
                break;
            };
        }

Neither of them works.

Did I missed something?

Thanks.

2
Can you tell why you need to find row from grid? Why do not get data from a bound bindingsourceHassan Eskandari
I need to highlight that Row.Tim

2 Answers

0
votes

LocateByValue works to me fine. Please check if first parameter is really FieldName. To be sure, I am using GridView.LocateByValue(colId.FieldName, value);

0
votes

In my case DataController.IsReady was false. Make sure you use this function after data has been loaded.