Dim tr As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim nd As WinForm.TreeNode
Dim dt As DataTable = DataTables("表A")
tr.StopRedraw()
tr.Nodes.Clear
tr.Nodes.Add("全部")
Dim dgDic As New Dictionary(of String,String)'递归记录,防止死循环
For Each dr As DataRow In dt.datarows
If dr.IsNull("父键") Then
nd = tr.Nodes.Add(dr("键"),dr("标题"))
Functions.Execute("AddChildren",nd,dt,dgDic)
End If
dgDic.Clear '一条递归用一套记录
Next
tr.ResumeRedraw()
内部函数:
以下内容只有回复后才可以浏览