Solved

Treeview Control: How to find "grandparent"

Posted on 2003-11-08
4
402 Views
Last Modified: 2013-12-26
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
0
Comment
Question by:damon98765
  • 3
4 Comments
 
LVL 2

Accepted Solution

by:
gimmeadrink earned 250 total points
Comment Utility
Use

Form1.TreeView1.SelectedItem.Parent.Parent

HTH
0
 
LVL 2

Expert Comment

by:gimmeadrink
Comment Utility
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
 

Author Comment

by:damon98765
Comment Utility
Thanks for the help.  Quick, easy & elegant.

D

0
 
LVL 2

Expert Comment

by:gimmeadrink
Comment Utility
np problem, thanks for the A :)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now