Control the location of the selected row, within the visible

TeeGrid VCL / FMX for Embarcadero RAD Studio, Delphi, C++ Builder and Lazarus Free Pascal.
Post Reply
REH Outsourcing
Newbie
Newbie
Posts: 25
Joined: Tue Mar 13, 2018 12:00 am

Control the location of the selected row, within the visible

Post by REH Outsourcing » Sat Jul 07, 2018 11:45 am

Delphi version: Seattle and Tokyo
TTeeGrid version: VCL & FMX Registered version-1.04
Multidevice Application (FMX)
Platform: WIN32

Hello,

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.


Greetings.

REH Outsourcing
Newbie
Newbie
Posts: 25
Joined: Tue Mar 13, 2018 12:00 am

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

Post by REH Outsourcing » Mon Jul 09, 2018 5:32 pm

This is a possible solution:

Code: Select all

type
   TGridAccess = class (TCustomTeeGrid);

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

var
   // Read the current Scroll position
   Y: = TeeGrid1.Grid.Current.Rows.Scroll.Y;
   X: = TeeGrid1.Grid.Current.Rows.Scroll.X;
  -- code...
  RestoreScroll(TeeGrid1,x,y);


Post Reply