Page 1 of 1

Control the location of the selected row, within the visible

Posted: Sat Jul 07, 2018 11:45 am
by 18683216
Delphi version: Seattle and Tokyo
TTeeGrid version: VCL & FMX Registered version-1.04
Multidevice Application (FMX)
Platform: WIN32


For example, if there are 20 rows but only 5 can be displayed in the TTeegrid window, how can I get that pe. row 15 is displayed as the first visible, currently using the method TTeeGrid.Selected.Change, row 15 is shown as the last visible and selected row.
In other words, how can I control the selected row and its position in the visible window (eg at the beginning in the middle or at the end), when there are more rows than can be displayed.

I need this, because as I commented in another post, when a TTeeGrid is associated with a descendant of a TDataSet, when the value of a cell row is modified , the row is deselected and if it is editing pe. row 15, the selected row becomes 0.
When the behavior should be, keep the row selected.
You can review this behavior in your Demo TeeGrid_FMX_DataSet_Demo, modifying the address field of the last record of ClientDataSet1 and pressing the Enter key.
You can see that immediately after, the first record is displayed.

In case it helps, in this case the vertical scroll bar does not change, when it should be at the top, since it is showing the first row.


Re: Control the location of the selected row, within the visible

Posted: Mon Jul 09, 2018 5:32 pm
by 18683216
This is a possible solution:

Code: Select all

   TGridAccess = class (TCustomTeeGrid);

procedure RestoreScroll (Grid:TTeeGrid, x, y: double);
   // Return the scroll to the original position
   TGridAccess (Grid). ChangeVertScroll (Y);
   TGridAccess (Grid). ChangeHorizScroll (X);

   // Read the current Scroll position
   Y: = TeeGrid1.Grid.Current.Rows.Scroll.Y;
   X: = TeeGrid1.Grid.Current.Rows.Scroll.X;
  -- code...