Dim nd As WinForm.TreeNode = Args(0)
Dim dt As DataTable = Args(1)
Dim drs As List(Of DataRow)
drs = dt.Select("[上级编码] = " & nd.Name)
For Each dr As DataRow In drs
Dim cd As Winform.TreeNode = nd.Nodes.Add(dr("本级编码"),"[" &dr("单位编码") &"]" &dr("单位名称"))
Functions.Execute("部门递归函数",cd,dt)
Next
生成的目录树:
此主题相关图片如下:搜狗截图20150728005147.png
定位展开节点:
Dim sc As Integer =Tables("单位表").Current("本级编码")
Dim tv As WinForm.TreeView = Forms("主窗口").Controls("TreeView2")
For Each nd As WinForm.TreeNode In tv.AllNodes
If nd.DataRow("本级编码") =sc Then
tv.SelectedNode = nd
nd.EnsureVisible
End If
Next
结果在红字处出现错误:
"未将对象引用设置到对象的实例。"
定位展开这段我是根据 LSY版主的一个例子改编的
请教各位:是不是递归函数的目录树和别的目录树不同?这句该怎么写?