Page 1 of 1

Teegrid scrolls to top after editing a cell

Posted: Fri Aug 15, 2025 9:27 am
by 114100772
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 1476 times

Re: Teegrid scrolls to top after editing a cell

Posted: Tue Aug 19, 2025 10:49 am
by Marc
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

Re: Teegrid scrolls to top after editing a cell

Posted: Tue Aug 19, 2025 11:33 am
by Marc
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

Re: Teegrid scrolls to top after editing a cell

Posted: Wed Aug 20, 2025 1:27 pm
by 114100772
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