Hello All, I am having problems adding a node were I want to. I made a routine which is passed a node (a node you want to add) and a parent node to specify what to add it under. This seems straightforward, but doesn't work in cases where you are trying to add a child node to a node that has no children. Any help would be greatly apreciated.
Here is my routine: '============================= Private Sub AddNode(ByVal node As TreeNode, Optional ByVal parent As TreeNode = Nothing) If parent Is Nothing Then 'ADD AT BOTTOM OF LIST TreeView1.Nodes.Add(node) Else 'ADD AS CHILD TO REQUESTED PARENT TreeView1.Nodes.Item(TreeView1.Nodes.IndexOf(parent)).Nodes.Add(node) End If End Sub '============================= Here is what calls the routine: '============================= Button1.Click: Dim tmpNode As New TreeNode() tmpNode.Text = "NEW NODE" AddNode(tmpNode, TreeView1.SelectedNode) '============================= You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.