I have an array of paths separated by a delimiter:
Dim paths = New List(Of String)() From { "C:\WINDOWS\AppPatch\MUI\040C", "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727", "C:\WINDOWS\Microsoft.NET\Framework\addins\MUI", "C:\WINDOWS\addins", "C:\WINDOWS\AppPatch", "C:\WINDOWS\AppPatch\MUI", "C:\WINDOWS\Microsoft.NET\Framework\MUI\MUI\0409" }
And I want to create a RadTreeView that will look something like this:
+C: +Windows +AppPatch +addins +Microsoft.NET +Framework...
This is what I have managed to do until now but there's something I'm missing:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim paths = New List(Of String)() From { "C:\WINDOWS\AppPatch\MUI\040C", "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727", "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\MUI", "C:\WINDOWS\addins", "C:\WINDOWS\AppPatch", "C:\WINDOWS\AppPatch\MUI", "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\MUI\0409" } If Not Page.IsPostBack Then Dim subPathAgg As String Dim pathSeparator As String = "\" ' For each complete individual path For Each path As String In paths subPathAgg = String.Empty ' Fill array of strings with each delimited part Dim arrFolders As List(Of String) = (path).Split(pathSeparator).ToList Dim lastNode As RadTreeNode = Nothing Dim iCount As Integer = 0 'For each one of the folders For Each folder As String In path.Split(pathSeparator) subPathAgg += folder & pathSeparator Dim foundNode As RadTreeNode = RadTreeView1.Nodes.FindNodeByValue(subPathAgg, True) If foundNode Is Nothing Then If lastNode Is Nothing Then lastNode = New RadTreeNode(folder, subPathAgg) RadTreeView1.Nodes.Add(lastNode) Else Dim otherNode = New RadTreeNode(folder, subPathAgg) lastNode.Nodes.Add(otherNode) lastNode = otherNode End If Else If foundNode.Text <> folder Then Dim otherNode = New RadTreeNode(folder, subPathAgg) foundNode.Nodes.Add(otherNode) lastNode = otherNode End If End If Next lastNode = Nothing Next End IfEnd Sub
This is how the RadTreeView looks like right now:
