Where’s My Last Record?
I’m saying about to keep last record position in memory & store it on next task. Pretty simple but it helps users effectively, at least minimize the use of scrolling. Here my example on Delphi, with TDBGrid contains records retrieved from a table & assigned with TQuery component. Once TQuery refreshed, record pointer will be at first position. To avoid this, save bookmark pointer before TQuery refreshed & store position in after. Check a code sliced below:
unit ULastRecordPointer;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, DBGrids, ComCtrls, DB, DBTables, ExtCtrls, JPEG;
type
TFLastRecordPointer = class(TForm)
...
private
{ Private declarations }
public
{ Public declarations }
end;
var
FLastRecordPointer: TFLastRecordPointer;
...
ptr_record: TBookmark;
implementation
{$R *.dfm}
procedure TFLastRecordPointer.FormRefresh(Sender: TObject);
begin
try
q3.GotoBookmark(ptr_record);
except
//
end;
end;
procedure TFLastRecordPointer.DBGrid1DblClick(Sender: TObject);
begin
ptr_record:=q3.GetBookmark;
end;
end.
The last record position will be saved if users had double clicking on grid (pick a record) & try to store it after the form refreshed. So that the small black triangle will stay on it’s previous position.
With this help of TBookmark, users job will assisted & no more times will be wasted. Furthermore, your users mouse will be much more durable ;-p
Labels: Delphi, My Tricks, My Works, MySQL
PS: If you've benefit from this blog, you can support it by making a small contribution. |
Post a Comment
Leave comments here...