Pregunta

I have a VirtualStringTree with X roots and X childnodes.

Every root has a special NodeData assigned. Every childnode has another NodeData assigned. How do I know OnFreeNode which is which? Cause I can't free the data without knowing which record is assigned to it. Any Ideas?

¿Fue útil?

Solución

To determine a node level use the GetNodeLevel function. It returns the 0 based level index, where 0 means a root node, 1 is for a root's child, 2 is for a root's grandchild etc.

So, in OnFreeNode event you can use something like this:

procedure TForm1.VirtualTreeFreeNode(Sender: TBaseVirtualTree;
  Node: PVirtualNode);
begin
  case VirtualTree.GetNodeLevel(Node) of
    0: // free your root node data
    1: // free your root's child node data
  end;
end;
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top