Quote 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:
  1. Private Sub AddChild(ByVal CurrentNode As TreeNode, _
  2.                    ByVal strText As String, ByVal intImage As Integer, _
  3.                    Optional ByVal intSelectImage As Integer = 99999)
  4.         Dim tvwnode As New TreeNode
  5.         With tvwnode
  6.             .Text = strText
  7.             .ImageIndex = intImage
  8.             If intSelectImage <> 99999 Then .SelectedImageIndex = intSelectImage Else .SelectedImageIndex = intImage
  9.         End With
  10.         CurrentNode.Nodes.Add(tvwnode)
  11.         TreeView1.ExpandAll()
  12.     End Sub

How would I alter this sub in order to return a reference to the newly added node?

Thanks!