Solved

Treeview Control: How to find "grandparent"

Posted on 2003-11-08
4
414 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 2

Accepted Solution

by:
gimmeadrink earned 250 total points
ID: 9708846
Use

Form1.TreeView1.SelectedItem.Parent.Parent

HTH
0
 
LVL 2

Expert Comment

by:gimmeadrink
ID: 9708848
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
ID: 9710387
Thanks for the help.  Quick, easy & elegant.

D

0
 
LVL 2

Expert Comment

by:gimmeadrink
ID: 9711573
np problem, thanks for the A :)
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…

733 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