MoveRowOnSort Does Not keep Active Row visible

MoveRowOnSort Does Not keep Active Row visible after sort.  Have played with KeepScrollOnSort also to no avail. Can keep active row active after sort but this row is not visible. Clicking the row twice has the desired effect of changing sort order but keeping active row visible in grid.


Thanks,

John

There is not a built-in setting to do this automatically.
You could do after sort:


grid.TopRow := grid.Row; to make the active row visible.

Thanks for your resonse. i can't find an event for AfterSort. I am sorting  by clicking on column headers.


Cheers,

The OnClickSort event is triggered after the sort is done from a click on a column header.

Only works if the active and destination rows are both visible in the grid at the time sort is initiated.  


If a grid has 20 visible rows and 120 total rows, sorting by a column can send the active row to position 107 for example, below the visible rows. Setting TopRow to Row has no effect in this situation.

Thanks again,

John

I have retested this here with:


procedure TForm1.AdvStringGrid1ClickSort(Sender: TObject; ACol: Integer);
begin
  //
  advstringgrid1.TopRow := advstringgrid1.Row;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  advstringgrid1.SaveFixedCells := false;
  advstringgrid1.LoadFromCSV('e:\tms\cars.csv');
  advstringgrid1.SortSettings.Show := true;
  advstringgrid1.Navigation.MoveRowOnSort := true;
end;

and I cannot see a problem. The grid scrolls to active row after sorting.

Thanks for your help. You are right, in most cases it works great. If you add DisjunctRowSelect it stops working. 

'

Thanks for your help. It works great without disjunct rows....