Add nodes in TreeView using VC++ 2003??

G

Guest

I'm struggling on this. My goal is to add nodes programmaticaly on a 3-level
tree. Unlike C#, VC++ 2003 cannot perform pointer arithmetic on
TreeNodeCollection. So I cannot do something like this:
this->trVw_CNS->Nodes[0]->Add("Root");

I tried an alternative, adding my root node this way:
this->trVw_CNS->Nodes->Add("Root");
and adding children of the root this way:
this->trVw_CNS->GetNodeAt(0, 0)->Nodes->Add("SonOfRoot");

However, I don't know how can I add grandson of root. GetNodeAt doesn't seem
to be the right method I should be using. Any ideas?

Many thanks!!
 
G

Guest

I found the answer! Add method has a return value which is of TreeNode type.
We can store this node to add its children.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top