Mega Code Archive

 
Categories / Delphi / ADO Database
 

How to Scroll within a DBGrid

Title: How to Scroll within a DBGrid //... private OldGridProc: TWndMethod; procedure GridWindowProc(var Message: TMessage); //... procedure TForm1.FormCreate(Sender: TObject); begin OldGridProc := DBGrid1.WindowProc; DBGrid1.WindowProc := GridWindowProc; end; procedure TForm1.GridWindowProc(var Message: TMessage); var Pos: SmallInt; begin OldGridProc(Message); if Message.Msg = WM_VSCROLL then //or WM_HSCROLL begin Pos := Message.WParamHi; //Scrollbox position Table1.RecNo := Pos; end; end;