Board index » delphi » TTreeView and TTreeNode.Data when to free

TTreeView and TTreeNode.Data when to free

Hi
    I am using the TTreeView control and want to store some additional data
in the nodes. I am doing this by:

   Node.Data := TMyClass.Create;
   TNodeData(Node.Data).sText := 'test';

I know how to free the class:

    TMyClass(Node.Data).Free;

but when should i do this?  When the form with the TTreeView control is
closed does delphi free the memory for me or do i need to do it myself?

Thankyou

Charlie

 

Re:TTreeView and TTreeNode.Data when to free


You can do it in the OnDeletion event of the Treeview.

Quote
Charlie Grosvenor wrote:
> Hi
>     I am using the TTreeView control and want to store some additional data
> in the nodes. I am doing this by:

>    Node.Data := TMyClass.Create;
>    TNodeData(Node.Data).sText := 'test';

> I know how to free the class:

>     TMyClass(Node.Data).Free;

> but when should i do this?  When the form with the TTreeView control is
> closed does delphi free the memory for me or do i need to do it myself?

> Thankyou

> Charlie

--
Guillermo Casta?o Acevedo
Gerente de Sistemas - Grupo Millennium Ltda
Guiller...@GrupoMillennium.com
www.GrupoMillennium.com

Other Threads