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.
DickSwart6Asked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
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
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
treeview.selectednode.parent
0
 
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.
0
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.

 
AHMKC1Commented:
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
 
danaseamanCommented:
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
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
point split
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.