?
Solved

Tree View

Posted on 2006-05-10
9
Medium Priority
?
163 Views
Last Modified: 2010-05-03
How can I get The name of the parent node when I click on a sub node. for Example:
Group Name
              Building Name
                         Floor Name
                                      Location Name

If I click on Location Name, how do I get the values for all the Nodes above it in code. (Run-time)

If you dont understand please let me know and I will post my code I've got.
0
Comment
Question by:DickSwart6
6 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 16646909
treeview.selectednode.parent
0
 

Author Comment

by:DickSwart6
ID: 16646958
If you look at my example. Woun't your answer only dive me 'floor name' if I select 'Location name'?

I'm looking for all the above.
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 172 total points
ID: 16646965
into 1 string:
treeview.selectednode.parent.Path

to loop:

dim p as Node
set p = treeview.selectednode
while not(p.parent is nothing)
  set p = p.parent
  debug.print p.caption
wend

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Assisted Solution

by:AHMKC1
AHMKC1 earned 164 total points
ID: 16648825
Try code given below at Treeview NodeCick Event

Dim I As Integer

I = Len(TreeView1.SelectedItem.FullPath) - Len(TreeView1.SelectedItem.Text) - 1

If I > 0 Then
     MsgBox Left(TreeView1.SelectedItem.FullPath, I)
Else
     MsgBox "This is the Root Node"
End If
0
 
LVL 22

Assisted Solution

by:danaseaman
danaseaman earned 164 total points
ID: 16649875
Option Explicit

Private Sub Form_Load()
   Dim i As Long
   Dim nod As Node
   Dim sArray() As String
   tv.Nodes.Add , , "Group Name", "Group Name"
   tv.Nodes.Add "Group Name", tvwChild, "Building Name", "Building Name"
   tv.Nodes.Add "Building Name", tvwChild, "Floor Name", "Floor Name"
   Set nod = tv.Nodes.Add("Floor Name", tvwChild, "Location Name", "Location Name")
   sArray = Split(nod.FullPath, "\")
   Debug.Print "Parent Nodes are:"
   For i = 0 To UBound(sArray) - 1
      Debug.Print sArray(i)
   Next
End Sub
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 16876648
point split
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month17 days, 8 hours left to enroll

830 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