Treeview Control: How to find "grandparent"

Hi all--

New to the VB6 treeview control.  I've found that it is easy to get a node's Parent, but what is the best way to find the Parent of a node's Parent (or grandparent as it were).

In other words:

Level 1
     Level 2
          Level 3

How can I find the Level 1 Information when Level 3 is selected?


Thanks,
Damon
damon98765Asked:
Who is Participating?
 
gimmeadrinkCommented:
Use

Form1.TreeView1.SelectedItem.Parent.Parent

HTH
0
 
gimmeadrinkCommented:
I suppose i should explain that better

[level3].parent as you know, gets the parent to the item in level3 (replace [level3] with whatever method you use to get that item).

but the parent of level3, is just another node, so therefore, you can use the parent property to get its parent. hence

[level3].parent.parent

i should have explained this better before.

0
 
damon98765Author Commented:
Thanks for the help.  Quick, easy & elegant.

D

0
 
gimmeadrinkCommented:
np problem, thanks for the A :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.