Tree View

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.
Who is Participating?
Guy Hengel [angelIII / a3]Billing EngineerCommented:
into 1 string:

to loop:

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

Guy Hengel [angelIII / a3]Billing EngineerCommented:
DickSwart6Author Commented:
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.
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

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)
     MsgBox "This is the Root Node"
End If
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)
End Sub
Guy Hengel [angelIII / a3]Billing EngineerCommented:
point split
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.