Good Morning,
I have a tree navigator that i am using to display
directory information in a more user friendly way to that. I am trying
to set a variable on the selectionchanged event which will take a
current path string from a global variable and then add text to from the
top level nodes down to the currently selcted one. I have done an
example below of what i am trying to achieve.
ExampleNode 1
Node 1.1
Node 1.2
Node 1.3
Node 1.3.1
Node 1.3.1.1
Node 1.3.2
Node 1.4
Node 2
Node3
So if Node 1 is selected then the output would be "Global Variable Text\Node 1"
If Node 1.3.1 is seelcted then the output would be "Global Variable Text\Node 1\Node 1.3\Node 1.3.1" but not node 1.3.1.1.
I have got the following code which is giving me all nodes as it recursivly however im trying to add a stop when it gets to the current node id however i cant find a node.index value
Private Sub TreeNavigatorDirectories_SelectionChanged(sender As TreeNavigator, e As SelectionStateChangedEventArgs) Handles TreeNavigatorDirectories.SelectionChanged
If TreeNavigatorDirectories.SelectedItem.HasChildren = False Then
strCurrent_Location = strFile_Location
strCurrent_Location = strCurrent_Location & "\" & Replace(TreeNavigatorDirectories.SelectedItem.Text, " ", "_")
Else
strCurrent_Location = strFile_Location
Dim Node As TreeMenuItem = sender.SelectedItem
strCurrent_Location = strCurrent_Location & "\" & String.Join("\", GetChildren(Node))
End If
AutoLabel1.Text = strCurrent_Location
End Sub
Private Function GetChildren(ParentNode As TreeMenuItem) As List(Of String)
Dim nodes As List(Of String) = New List(Of String)
GetAllChildren(ParentNode, nodes)
Return nodes
End Function
Private Sub GetAllChildren(ParentNode As TreeMenuItem, nodes As List(Of String))
For Each childnode As TreeMenuItem In ParentNode.Items
nodes.Add(childnode.Text)
GetAllChildren(childnode, nodes)
Next
End Sub
I hope this makes sense and i look forward to hearing from you
Frosty