这个程序是一个用 VB 2008 编写的 Windows 窗体应用程序我有一个数据表 (dtSubFolders),我通过它迭代以通过将其 NodesCollection 发送到递归子例程来填充树视图 (tv_Folder_Hierarchy)。正如底部的数据所证明的那样,NodesCollection 似乎正在正确填充。但是,当我展开根目录时,我看到它的 7 个子节点,然后我得到一个 vs32host.exe 已停止工作错误。
For Each row In dtSubFolders.Rows
m_folder_Node = New TreeNode
Get_TV_Node(tv_Folder_Hierarchy.Nodes, row(1).ToString)
If Len(m_folder_Node.Name) > 0 Then
m_folder_Node.Nodes.Add(row(0).ToString, row(2))
Else
tv_Folder_Hierarchy.Nodes.Add(row(0).ToString, row(2))
End If
Next
Private Sub Get_TV_Node(ByRef Nodes As TreeNodeCollection, ByVal Name As String)
Dim node As TreeNode
If Len(m_folder_Node.Name) = 0 Then
For Each node In Nodes
If node.Name = Name Then
m_folder_Node = node
Exit For
Else
If node.Nodes.Count > 0 Then Get_TV_Node(node.Nodes, Name)
End If
Next
End If
End Sub
ID Parent Kids Text
1811 None 7 根文件夹
1818 1811 40 Award Creation
1828 1818 0 Award Creation Sub 1
1819 1818 0 Award Creation Sub 2
1824 1818 0 Award Creation Sub 3
1839 1818 0 Award Creation Sub 4