Mirror

Replace the default scrollbar of a TStringGrid with buttons (Views: 100)


Problem/Question/Abstract:

I want to put two buttons as a scrollbar to my grid instead of using the default Delphi windows scrollbar. I suppose that I should handle the messages like WM_VSCROLL and WM_HSCROLL and setting my grid.Scrollbars := none

Answer:

You should send these messages to the grid on your button presses, e.g. for a line up:

{ ... }
with stringgrid1 do
begin
  perform(WM_VSCROLL, SB_LINEUP, 0);
  perform(WM_VSCROLL, SB_ENDSCROLL, 0);
end;

or use:

procedure buttonupClick(sender);
begin
  SendMessage(Grid1.Handle, WM_VSCROLL, SB_LINEUP, 0)
end;

<< Back to main page