Solved

# Tree View

Posted on 2006-05-10
Medium Priority
163 Views
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
Question by:DickSwart6

LVL 143

Expert Comment

ID: 16646909
treeview.selectednode.parent
0

Author Comment

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

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

LVL 6

Assisted Solution

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

danaseaman earned 164 total points
ID: 16649875
Option Explicit

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

ID: 16876648
point split
0

## Featured Post

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