code_junkie

TDBGrid onSelect

Nov 13th, 2011
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. implementation
  2.  
  3. {$R *.dfm}
  4.  
  5. type
  6. THackDBGrid = class(TDBGrid);
  7. //for info on why we must do this, see:
  8. //http://delphi.about.com/od/oopindelphi/l/aa082603a.htm
  9.  
  10. var
  11. LastValidRow: integer;
  12.  
  13. procedure TForm1.DataSource1DataChange(Sender: TObject; Field: TField);
  14. begin
  15. //assign this to the TDBGrid.DataSource.DataSet.OnDataChange Event
  16. if 0 <> HiWord(GetKeyState(VK_LBUTTON)) then begin
  17. THackDBGrid(DBGrid1).Row := LastValidRow;
  18. end
  19. else begin
  20. LastValidRow := THackDBGrid(DBGrid1).Row;
  21. inherited;
  22. end;
  23. end;
Add Comment
Please, Sign In to add comment