Question

I have this Devexpress 13 Xtragrid.gridcontrol and I can find the row that is selected, using this code:

int[] selRows = ((Gridview))grdMygrid.Mainview).GetSelectedRows();
DataRowView selRow (DataRowView)(((Gridview)grdMyView.MainView).GetRow(selRows[0]));
int SelectedIndex = selRows[0];

Now, this works like a charm... Only I added some navigation buttons with which I want to be able to scroll through the gridcontrol. (next, previous, last, first)

I can't seem to set the row in code. Somebody here have an idea on how to accomplish this?

I'm looking for something like this:

myGrid.SelectedRow = SelectedIndex();
Was it helpful?

Solution

You should set the FocusedRowHandle of the main view of your grid.

If you have named it ViewMain (as i usually do) you may :

ViewMain.FocusedRowHandle = SelectedIndex();

or you may cast the MainView property of your grid to GridView and set the FocusedRowHandle property:

((DevExpress.XtraGrid.Views.Grid.GridView)myGrid.MainView).FocusedRowHandle = SelectedIndex();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top