1

I am using the Janus GridEx control. I am using a timer to update the grid with data from the database every minute. If the user has a row selected when the data is updated from the database, how can I re-select the row after the update is complete?

kevev22
  • 3,737
  • 21
  • 32
Pouya
  • 1,908
  • 17
  • 56
  • 78

1 Answers1

5

You should store the index of the row that is selected before you refresh the grid, then set the selected row to that value after. Something like:

int row = myGrid.Row;

// Perform update

try
{
    vJanusDataGridMeasures.Row = row;
}
// The row index that was selected no longer exists.
// You could avoid this error by checking this first.
catch (IndexOutOfRangeException)
{
    // Check to see if there are any rows and if there are select the first one
    if(vJanusDataGridMeasures.GetRows().Any())
    {
        vJanusDataGridMeasures.Row = 0;
    }
}
kevev22
  • 3,737
  • 21
  • 32