Treeview add node as Child

E

Elmo Watson

with VB6 - to add a node as a child, to a specific node, I'd do something
like:
Tv1.Nodes.Add(Nodes.Add tv1.SelectedItem.Key, tvwChild, newKey, NewName
tv1.SelectedItem.Key was the Parent node -

But - as I'm trying to add something in, using VS.Net 2005 (skipped here
straight from vb6), the hints aren't giving me the same options -

Relative (1st item), and Relationship (2nd option) are not even
available....

where can I find info on how to do this in VS.Net 2005?
 
L

Lloyd Sheen

There is a new structure to the API for treeviews. Each node will have its
own collection of nodes. This is much easier if you think about it since it
deals with nodes rather than the treeview. In dot.net V1.+ there is no way
to identify the nodes with a key but this is back in with V2.+.

This means that you get a reference to the node you want as the parent and
then add nodes to that.

Hope this helps.


Lloyd Sheen
 
E

Elmo Watson

OK - so I want to add a child node to a parent node - -
HOW do I get a reference to the Parent?

I've found you can't even do a 'Dim sNode as Node' anymore - it doesn't like
'as Node'

Is there somewhere else ( a web page, or the like) that has an actual
example of all this?
 
P

Peter Oliphant

Each TreeNode has a Parent property. I believe you keep looking at the
parents (i.e., this is my parent, this is my parent's parent, this is my
parent's parent's parent, etc.) eventually you get one that has no parent.
That should be the root node in the TreeView they are attached to (the
refeence you are asking for)...

At least I THINK that's what you asked for... : )

[==P==]
 

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