J
Jan Krouwer
I have a treeview which is populated from a relational database. In order to
copy part of the tree, I need to add to the database the relationship of the
part of the tree to be copied but with new ids. I have built a collection of
the right number of ids. I am using the following code to recursively go
through the tree (some code left out). Pos is the position in the collection
of ids - I need to select the correct ids (need to use previous ids) to
maintain the node relationship which is done by testing node properties.
What is strange is that pos is the correct number in this routine but when
the last node is reached, pos changes to the wrong number. Any ideas or
another way to add a hierarchical relationship to a database from a set of
treeview nodes.
Private Sub Copy(ByVal n As TreeNode, ByVal pos As Integer)
Dim aNode As TreeNode
pos=pos+1
For Each aNode In n.Nodes
Copy(aNode, pos)
Next
End Sub
' Call the procedure using the top nodes of the treeview.
Private Sub CopyStart(ByVal aTreeView As TreeView)
Dim n As TreeNode
For Each n In aTreeView.Nodes
Copy(n,1)
Next
End Sub
copy part of the tree, I need to add to the database the relationship of the
part of the tree to be copied but with new ids. I have built a collection of
the right number of ids. I am using the following code to recursively go
through the tree (some code left out). Pos is the position in the collection
of ids - I need to select the correct ids (need to use previous ids) to
maintain the node relationship which is done by testing node properties.
What is strange is that pos is the correct number in this routine but when
the last node is reached, pos changes to the wrong number. Any ideas or
another way to add a hierarchical relationship to a database from a set of
treeview nodes.
Private Sub Copy(ByVal n As TreeNode, ByVal pos As Integer)
Dim aNode As TreeNode
pos=pos+1
For Each aNode In n.Nodes
Copy(aNode, pos)
Next
End Sub
' Call the procedure using the top nodes of the treeview.
Private Sub CopyStart(ByVal aTreeView As TreeView)
Dim n As TreeNode
For Each n In aTreeView.Nodes
Copy(n,1)
Next
End Sub