[Lazarus] Synchronize scrollposition of two stringgrids

Rimmert Ooink lazarus at ooink.net
Mon Oct 22 20:25:38 CEST 2012

On Tue, Oct 16, 2012 at 8:55 AM, Rimmert Ooink <lazarus at ooink.net> wrote:
> On Tue, Oct 16, 2012 at 1:54 AM, Jesus Reyes <jesusrmx at yahoo.com.mx> wrote:
>>> Does anybody have an idea how to change the scrollposition of a stringgrid depending on the scrollpos of the other?
>> sg1.LeftCol := sg2.LeftCol;
>> For pixel granularity, without messing with grids internals, could be done using GetScrollInfo for both scrollbars on source grid and using SetScrollInfo for both scrollbars on target grid.

Anybody an idea why the code below doesn't work?
GetScrollBarPosition does seem to return the correct value, but the
call to ScrollbarPosition doesn't seem to work.
On windows it actually cals SetScrollInfo as mentioned, but doesn't
seem to do anything.


  TGridHack = class(TStringGrid)
    procedure SyncTo(grd: TStringGrid);


{ TGridHack }

procedure TGridHack.SyncTo(grd: TStringGrid);
  //LeftCol := grd.LeftCol;
  ScrollBarPosition(SB_Horz, TGridHack(grd).GetScrollBarPosition(SB_Horz));
  //ScrollBarPosition(SB_Vert, TGridHack(grd).GetScrollBarPosition(SB_Vert));

More information about the Lazarus mailing list