Tim
Tim

Reputation: 459

c# devexpress xtragrid LocateByValue is not working

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.

Upvotes: 0

Views: 1379

Answers (2)

Tone Škoda
Tone Škoda

Reputation: 1523

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

Upvotes: 0

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

Upvotes: 0

Related Questions