Dim nd As WinForm.TreeNode
For Each dr As DataRow In DataTables("表A").Select("","类别")
Dim Path As String = dr("类别")
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 = e.Form.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 1:00:34编辑过]