Help needed with For Each Childnode

morphnike

Active member
Joined
Oct 8, 2005
Messages
25
Programming Experience
1-3
Guys, need some help with the following problem
the following code deletes all the records of the selected node + the childnodes. But I need to start with the last childnode instead of the first (otherwise it will give an error when a node has 3 or more childnodes).
How can I start the loop with the last childnode?

For Each node As TreeNode In trvCat.CheckedNodes
For Each node2 As TreeNode In node.ChildNodes
deleteKnw(node2.ToolTip)
tblCat.catId = node2.ToolTip
tblCat.delete()
Next
deleteKnw(node.ToolTip)
tblCat.catId = node.ToolTip
tblCat.delete()
Next

Thanks in advance

Morph 'n Nike
 
Use a For loop instead of a For Each loop. Then just start the index at the end and and Step backwards:
VB.NET:
For i As Integer = myCollection.Count - 1 To 0 Step -1
 
Back
Top