Dim nd As WinForm.TreeNode
Dim Names As List(Of String) = DataTables("表A").GetUniqueValues("类别 Is not Null", "类别")
For Each Name As String In Names
Dim Path As String = Name
Dim Parts() As String = Path.Split("\")
Dim Start As Integer
If nd IsNot Nothing Then
Do
If Path.StartsWith(nd.FullPath) Then
Start = nd.Level + 1
nd = nd.Nodes.Add(Parts(Start),Parts(start))
Start = nd.Level + 1
Exit do
Else
nd = nd.ParentNode
If nd Is Nothing Then
Exit do
End If
End If
Loop
End If
If nd Is Nothing Then
nd = Forms("窗口1").Controls("TreeView1").Nodes.Add(Parts(0),Parts(0))
start = 1
End If
For i As Integer = Start To Parts.Length - 1
nd = nd.Nodes.Add(Parts(i),Parts(i))
Next
Next
[此贴子已经被作者于2010-3-24 20:51:44编辑过]