不用排序也行,我给你完整的答案,AddChidren这个函数的代码改为:
Dim nd As WinForm.TreeNode = args(0)
Dim dt As DataTable = args(1)
For Each dr As DataRow In dt.Select("","科目代码")
Dim km As String = dr("科目代码")
If km.StartsWith(nd.name) AndAlso km.Length = nd.Name.Length + 2 Then
Dim cd As Winform.TreeNode = nd.Nodes.Add(km,km & " " & dr("科目名称"))
Functions.Execute("AddChildren",cd,dt)
End If
Next
窗口1的AfterLoad事件代码改为:
Dim tr As WinForm.TreeView = e.Form.Controls("TreeView1")
Dim nd As WinForm.TreeNode
Dim dt As DataTable = DataTables("会计科目")
tr.StopRedraw()
tr.Nodes.Clear
tr.Nodes.Add("全部")
For Each dr As DataRow In dt.Select("","科目代码")
If dr.IsNull("科目代码") = False AndAlso dr("科目代码").Length = 4 Then
nd = tr.Nodes.Add(dr("科目代码"),dr("科目代码") & " " & dr("科目名称"))
Functions.Execute("AddChildren",nd,dt)
End If
Next
tr.ResumeRedraw()
[此贴子已经被作者于2013-9-23 17:08:22编辑过]