level42
level42

Reputation: 987

How to extract the contents of a sub node, TreeView

I have a treeview in the following format:

Item1
--Description1
Item2
--Description2

Etc

I've got the following piece of code:

TextBox1.text = TreeView.Nodes(0).ToString

This puts the contets of Node 1 (In this case "Item1") into the text box.

However, if I put Nodes(1).ToString, it will put "Item2" into the text box.

My question is, how can I get the contents of the first sub-node?

I would like "Description1" to be placed in the TextBox.

Thanks.

[Edit] Also, how can I strip off the "TreeNode: " tag that seems to be generated?

Upvotes: 0

Views: 133

Answers (1)

the_lotus
the_lotus

Reputation: 12748

You can get the child nodes by accessing the nodes property. In your case, it would be:

TreeView.Nodes(0).Nodes(0).ToString

If you want to store specific information for a node, you can do it through the Tag property or just use substring to get the part of the string you want.

Upvotes: 1

Related Questions