Be sure to change the keys to something unique.
VB Code:
Private Sub TreeView1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single) Dim objNode As Node If Button = vbRightButton Then If (TreeView1.SelectedItem Is Nothing) Then ' Nothing selected - add to the root. Set objNode = TreeView1.Nodes.Add(, , "MustBeUnique", "[Change the Text]") Else ' A node was right clicked on - might as well add the node there. Set objNode = TreeView1.Nodes.Add(TreeView1.SelectedItem.Key, tvwChild, "UniqueKeyAgain", "[Child Node]") End If objNode.Selected = True TreeView1.StartLabelEdit End If End Sub




Reply With Quote