How to create a Virtual String Tree in Delphi

Asked

Viewed 337 times

2

What happens is that I created a Virtual String Tree in Delphi (Typhon64), but I don’t know how to add parent and child nodes to create the tree, I looked at the documentation but only found click events that creates deletes and edits nodes(Node), I need to create this dynamic tree until then I can do this only by using click event and adding the nodes with addChild(nil) method, but that’s not what I want what I want is that as soon as I load the form the Virtual String Tree already load with the nodes(nodes) and the name of the nodes and strings I define, no matter whether it’s string or an array of strings, since it creates the tree with parents and children I’m very grateful for the help!

until then my Virtual String Tree is like the image below:

http://oi59.tinypic.com/xl9jwz.jpg

inserir a descrição da imagem aqui

I would like to create a tree as the example below, but the values I will define:

http://oi62.tinypic.com/xgjx2u.jpg inserir a descrição da imagem aqui

  • could attach the images in question? I do not have access to the company tinypic

  • Ready the image above would be the Virtual String Tree, I need to make a tree with parents and children equal to the image below, I can even add the elements but with click event, only I need to make it load the tree when open the form.

  • It wouldn’t just put in the onCreate event in the form what you did in the click event?

  • list.Addchild(nil); // list is id of the Virtual String Tree and Addchild is the method that adds the node(Node) that would be the parent element of the tree

1 answer

0

To add a parent node declare a type variable PVirtualNode:

pai: PVirtualNode;

Give a command to start editing the grid before you start inserting the nodes:

vstGrid.BeginUpdate;

Add the parent node this way:

pai := vstGrid.AddChild(nil, ["Conteúdo do nó"]);

To add children pass the parent in the first parameter:

vstGrid.AddChild(pai, ["Conteúdo do nó"]);

To create this in the opening of the form make a loop on OnShow using the commands mentioned above. This will vary according to how you are bringing this information.

After you finish inserting the nodes give a command to finish editing the grid:

vstGrid.EndUpdate;

If you want to bring the expanded nodes use the command:

vstGrid.FullExpand;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.