
Originally Posted by
jmcilhinney
Why don't you have the AddChild method return a reference to the newly added node? That way you can simply pass that reference as the first argument to the next call to AddChild.
As to your error, the index of the last node is Count-1, not Count+1.
Thanks for the post. The following code is my AddChild Sub:
VB Code:
Private Sub AddChild(ByVal CurrentNode As TreeNode, _
ByVal strText As String, ByVal intImage As Integer, _
Optional ByVal intSelectImage As Integer = 99999)
Dim tvwnode As New TreeNode
With tvwnode
.Text = strText
.ImageIndex = intImage
If intSelectImage <> 99999 Then .SelectedImageIndex = intSelectImage Else .SelectedImageIndex = intImage
End With
CurrentNode.Nodes.Add(tvwnode)
TreeView1.ExpandAll()
End Sub
How would I alter this sub in order to return a reference to the newly added node?
Thanks!