试试这个:
Dim tr As WinForm.TreeView = e.Form.Controls("会计科目.TV")
Dim nd As WinForm.TreeNode
Dim dt As DataTable = DataTables("会计科目")
tr.StopRedraw()
tr.Nodes.Clear
For Each rt As String In DataTables("科目类别").GetComboListString("编码名称").split("|")
tr.Nodes.Add(rt)
Next
Dim gz As String = DataTables("分类编码方案").Find("基础档案名称 = '会计科目'")("编码规则")
For Each dr As DataRow In dt.Select("","编码规则")
If dr.IsNull("编码规则") = False AndAlso dr("编码规则").Length = val(gz(0)) Then
Dim i As Integer = CInt(dr("编码规则").Substring(0,1))
nd = tr.Nodes(i).Nodes.Add(dr("编码规则"),dr("编码规则") & " " & dr("编码名称"))
Functions.Execute("AddChildren",nd,dt,gz)
End If
Next
tr.ResumeRedraw()