[Lazarus] How TDBGrid works

Martin Schreiber mse00000 at gmail.com
Sat May 7 08:26:38 CEST 2016


On Friday 06 May 2016 23:20:41 Aradeonas wrote:
> Thanks.
>
> So what is the best way to provide those 100 to 1100 record at least
> without Dataset calling AfterScroll event?
> I want to not make any event while scrolling my custom Grid so other
> connected DB controls change their values otherwise while Im scrolling
> my custom grid it will cause calling all connected DB controls to update
> their values.
> I hope it is more clear now.
>
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.

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.

Martin




More information about the Lazarus mailing list