Recent

Author Topic: Set Recordnumber in DBgrid  (Read 1063 times)

madref

  • Hero Member
  • *****
  • Posts: 1079
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
Set Recordnumber in DBgrid
« on: June 13, 2024, 12:56:35 am »
With the following code you can see what record is selected in the dataset.
Code: Pascal  [Select][+][-]
  1. DBGrid.DataSource.DataSet.RecNo
How can I go to that recordnumber after a refresh without using the following code:
Code: Pascal  [Select][+][-]
  1. Q_Evaluaties.Locate('ID;TBL', VarArrayOf([Save_ID, Save_RL]), []);
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Main Platform:
--------------
Mac OS X Sonoma 14.7
Lazarus 3.99 (Lazarus 3.99 (rev main_3_99-2668-g6b352d830e) FPC 3.3.1 x86_64-darwin-cocoa)

Windows 10 Pro
Lazarus 3.99 (rev cbfd80ce39)

madref

  • Hero Member
  • *****
  • Posts: 1079
  • ..... A day not Laughed is a day wasted !!
    • Nursing With Humour
Re: Set Recordnumber in DBgrid
« Reply #1 on: June 17, 2024, 10:44:41 pm »
Any one???
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Main Platform:
--------------
Mac OS X Sonoma 14.7
Lazarus 3.99 (Lazarus 3.99 (rev main_3_99-2668-g6b352d830e) FPC 3.3.1 x86_64-darwin-cocoa)

Windows 10 Pro
Lazarus 3.99 (rev cbfd80ce39)

cdbc

  • Hero Member
  • *****
  • Posts: 1664
    • http://www.cdbc.dk
Re: Set Recordnumber in DBgrid
« Reply #2 on: June 17, 2024, 11:30:08 pm »
Hi
IIRC TDataset implements 'Bookmarks', as I remember they're easy to use...
Try looking it/them up, they've been there since Delphi 2
edit: Just looked it up in 'TDataset', it's a property of TDataset, of type 'TBookmark'; you set a local/tmp variable equal to it -> do your refresh -> then set it back again:
Code: Pascal  [Select][+][-]
  1. var tmpBkMrk: TBookmark;
  2. begin
  3.   ...
  4.   tmpBkMrk:= myDataset.Bookmak;
  5.   myDataset.Refresh; // or something like that
  6.   myDataset.Bookmark:= tmpBkMrk;
  7.   ...
  8. end;
  9.  
HTH
Regards Benny
« Last Edit: June 17, 2024, 11:46:10 pm by cdbc »
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

 

TinyPortal © 2005-2018