[Lazarus] TTreenode.data

Richard Mace richard.mace at gmail.com
Tue Sep 17 07:16:29 CEST 2013


Thanks Antonio, that worked fine.
Goodness knows what I was originally doing!

Richard

>
>   Details are missing about your implementation: Lzarus & FPC, OS, etc.
> I've made a little test on Win32 and Linux_X64, Lazarus 1.0.12
> I added some nodes to the TTreeView like this:
>
> var
>   SData: Integer=179;
>
> procedure TFrmMain.BtnTestTvClick(Sender: TObject);
> var
>   wNode: TTreeNode = nil;
>   s: String;
> begin
>   Inc(SData);
>   wNode := Ttv.Items.AddChildObject(nil, 'node new', Pointer(SData));
>   s := Format('node %s data:%d', [wNode.Text, PtrInt(wNode.Data)]);
>   MessageDlg('Titre', s, mtInformation, [mbOK], 0, mbOK);
> end;
>
> The I added an event to Ttv.OnChange event like that:
> procedure TFrmMain.TtvChange(Sender: TObject; Node: TTreeNode);
> var
>   wData: Integer;
> begin
>   if Assigned(Node) then begin
>     wData := PtrInt(Node.Data);
>     MessageDlg('Titre',Format('data for "%s" %d', [Node.Text, wData]),
> mtInformation, [mbOK], 0, mbOK);
>   end;
> end;
>
> I get a new node on every BtnTestTvClick and a value starting from 180 on
> every OnChange event
> On both platforms.
>
> Antonio.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20130917/34e999ce/attachment-0003.html>


More information about the Lazarus mailing list