Teegrid scrolls to top after editing a cell

TeeGrid VCL / FMX for Embarcadero RAD Studio, Delphi, C++ Builder and Lazarus Free Pascal.
Post Reply
ronald
Newbie
Newbie
Posts: 2
Joined: Thu Aug 14, 2025 12:00 am

Teegrid scrolls to top after editing a cell

Post by ronald » Fri Aug 15, 2025 9:27 am

Hi,

I noticed the following behavior which I'm not able to solve as of yet:
When editing a cell and pressing enter the teegrid scrolls back to the top. It doesn't stay at the same row.

How to reproduce:
1. Place a Teegrid on a form together with a TDatasource and a TClientDataset.
2. Define some fields on the TClientDataSet, right click and choose "Create Dataset".
3. In the code fille the dataset with some rows (more than would fit into the view area of the grid)
4. Scroll to the bottom and edit a cell and press enter (or tab)
5. The grid scrolls to the top

I would expect no scrolling whatsoever after pressing enter.

I'm using a licensed version v1.18 and Delphi 10.4 Version 27.0.38860.1461

See attached for example code and GIF.
TeeGridScrollsToTop.gif
TeeGridScrollsToTop.gif (201.75 KiB) Viewed 1435 times
Attachments
ExampleSource.zip
(1.38 KiB) Downloaded 25 times

Marc
Site Admin
Site Admin
Posts: 1341
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: Teegrid scrolls to top after editing a cell

Post by Marc » Tue Aug 19, 2025 10:49 am

Hello,

Just to let you know that we are looking at this issue, the solution to which has eluded us for some time. We'll get back to this thread with feedback.

Regards,
Marc Meumann
Steema Support

Marc
Site Admin
Site Admin
Posts: 1341
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: Teegrid scrolls to top after editing a cell

Post by Marc » Tue Aug 19, 2025 11:33 am

Hello,

This code keeps the current cell location after edit. We'll see what we can do to internalise the technique.

Code: Select all

var
  Form1: TForm1;
  scrollPos : TPointF;
  hasPainted : Boolean;

procedure TForm1.FormCreate(Sender: TObject);
begin
  hasPainted := false;
end;

procedure TForm1.TeeGrid1AfterDraw(Sender: TObject);
begin
  if not hasPainted then
  Begin
    hasPainted := True;
    teeGrid1.Rows.Scroll := scrollPos;
    teeGrid1.Repaint;
  End;
end;

procedure TForm1.TeeGrid1CellEdited(const Sender: TObject;
  const AEditor: TControl; const AColumn: TColumn; const ARow: Integer;
  var ChangeData: Boolean; var NewData: string);
Var myKey : char;
begin
   scrollPos := teeGrid1.Rows.Scroll;
   hasPainted := false;
end;
Regards,
Marc

ronald
Newbie
Newbie
Posts: 2
Joined: Thu Aug 14, 2025 12:00 am

Re: Teegrid scrolls to top after editing a cell

Post by ronald » Wed Aug 20, 2025 1:27 pm

Thanks, It works a bit better but only if the mouse cursor stays within the area of the grid.
If the mouse cursor is outside of the grid and you use the keyboard to edit values, then a draw event is not triggered and the grid goes again to the top but stays there.
If that can be fixed then it should be fine.
Cheers,
Ronald

Post Reply