[Lazarus] TTreenode.data

Flávio Etrusco flavio.etrusco at gmail.com
Thu Sep 12 01:16:09 CEST 2013


On Wed, Sep 11, 2013 at 6:19 AM, Graeme Geldenhuys
<graeme at geldenhuys.co.uk> wrote:
> On 2013-09-11 06:51, Richard Mace wrote:
>> Can anyone give me an example of adding and retrieving an integer value to
>> a TTreenode via it's data property please?
>
> The Data property holds a pointer value, so don't assign an Integer
> directly. Rather define a Record structure (or a Class) that holds the
> data you want (in your case an Integer field), then assign the pointer
> to the record structure to the Treenode.Data property.
>
> There is an example in the LCL documentation:
>
>   http://lazarus-ccr.sourceforge.net/docs/lcl/comctrls/ttreenode.data.html
>
>
> Regards,
>   Graeme

I don't agree this is a rule of thumb. If you know what you're doing
you should store whatever data fits in Data (pointer size) and avoid
the hundreds of tiny annoying allocations...

Regards,
Flávio




More information about the Lazarus mailing list