[Lazarus] TTreenode.data

Richard Mace richard.mace at gmail.com
Fri Sep 13 07:48:32 CEST 2013


OK, I now have this code:
with
tvMain.Items.AddChildObject(tvMain.Selected,IntToStr(fUserList.Items[I].Id),Pointer(fUserList.Items[I].Id))
do

and this:
procedure TfrmMain.tvMainChange(Sender: TObject; Node: TTreeNode);
begin
  if Assigned(Node.Data) then
    ShowMessage('Node ' + IntToStr(PtrInt(Node.Data)));
end;

And I am now getting an exception when my app run?

Richard

On 11 September 2013 09:24, Antonio Fortuny <a.fortuny at sitasoftware.lu>wrote:

>
> Le 11/09/2013 07:51, Richard Mace a écrit :
>
>  Hi,
> Can anyone give me an example of adding and retrieving an integer value to
> a TTreenode via it's data property please?
>
>  I've tried the below, but it doesn't seem to work.
>
>  Set:
>  with
> tvMain.Items.AddChildObject(tvMain.Selected,'string',TObject(fUserList.Items[I].Id))
> do
>
> change to:
> with tvMain.Items.AddChildObject(tvMain.Selected,'string', *Pointer*(fUserList.Items[I].Id))
> do
>
>
>
>  and getting as, throws an exception on start:
>  procedure TfrmMain.tvMainChange(Sender: TObject; Node: TTreeNode);
> begin
>    ShowMessage('Node ' + IntToStr(Integer(Node.Data)));
>
> change to:
> ShowMessage('Node ' + IntToStr(*PtrInt***(Node.Data)));
>
> Antonio.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20130913/9a526e55/attachment-0003.html>


More information about the Lazarus mailing list