[Lazarus] How TDBGrid works

Aradeonas aradeonas at operamail.com
Sat May 7 11:03:28 CEST 2016

> The easy one is probably to make two independent connections to the
> database. More elaborated solutions would be for example copy all said
> records to a memdataset and only connect that to a dbgrid, OR put the
> records in a non-dataset enabled component, like a TDrawGrid or
> TStringGrid, browsing that will not trigger any dataset events so
> other db controls will be unaffected, etc. The problem here is I think
> synchronizing stuff, you will have a funny time getting the updates to
> those records into the original source.
Jesus I'm afraid your way is not memory efficent.

> If the wanted record is in window of
> TDataLink.FirstRecord..FirstRecord + BufferCount - 1 you can
> temporarily switch the record which supplies the field data by setting
> TDatalink.ActiveRecord which doesn't fire any events. I assume you
> know that. ;-) See for example the MSEgui functions
> TGridDatalink.GetDisplay*Buffer(), BeginGridRow() and EndGridRow().
> https://gitlab.com/mseide-msegui/mseide-msegui/raw/master/lib/common/db/msedbedit.pas
> If the wanted records are anywhere in the dataset you need a dataset
> with random row data access. TMSEBufDataset supports it, please see
> the TMSEBufDataset.Current* properties.
> https://gitlab.com/mseide-msegui/mseide-msegui/raw/master/lib/common/db/msebufdataset.pas
> The MSEgui dropdownlist DB-edits use this approach for lookups if
> Dropdown.OptionsDB odb_directdata is set.
Glad to hear from you Martin. Happy to see MSE support this and I will
look it up.

> A possible workaround could be to call TDataset.DisableControls(), to
> fetch the needed records and to restore the DB cursor position before
> calling EnableControls(). I fear it is not efficient and has
> sideeffects.
What side effects do you think about?

http://www.fastmail.com - IMAP accessible web-mail

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20160507/3726f80e/attachment-0003.html>

More information about the Lazarus mailing list