Hi Everyone,
Can someone please tell me how the keys work in the VB TreeView control? I have set up the key to be "N0" but I keep getting an invalid key error. I would appreciate any help. Thank you.
Printable View
Hi Everyone,
Can someone please tell me how the keys work in the VB TreeView control? I have set up the key to be "N0" but I keep getting an invalid key error. I would appreciate any help. Thank you.
The key needs to be unique in all of the TreeView's Nodes, Including Root and Child Nodes. If you use "NO" more then once, you will get an error.
Here is an example of a setting up root and child nodes with keys:
Code:Private Sub Form_Load()
TreeView1.LineStyle = tvwRootLines
With TreeView1.Nodes
Call .Add(, tvwChild, "Root1Key", "Root1")
Call .Add("Root1Key", tvwChild, "Child1AKey", "Child1")
Call .Add("Root1Key", tvwChild, "Child2AKey", "Child2")
Call .Add("Root1Key", tvwChild, "Child3AKey", "Child3")
Call .Add("Root1Key", tvwChild, "Child4AKey", "Child4")
Call .Add("Root1Key", tvwChild, "Child5AKey", "Child5")
Call .Add("Child5AKey", tvwChild, "Child6AKey", "Child6")
Call .Add("Child5AKey", tvwChild, "Child7AKey", "Child7")
Call .Add("Child5AKey", tvwChild, "Child8AKey", "Child8")
Call .Add(, tvwChild, "Root2Key", "Root2")
Call .Add("Root2Key", tvwChild, "Child1BKey", "Child1")
Call .Add("Root2Key", tvwChild, "Child2BKey", "Child2")
Call .Add("Root2Key", tvwChild, "Child3BKey", "Child3")
Call .Add("Root2Key", tvwChild, "Child4BKey", "Child4")
Call .Add("Root2Key", tvwChild, "Child5BKey", "Child5")
Call .Add("Child5BKey", tvwChild, "Child6BKey", "Child6")
Call .Add("Child5BKey", tvwChild, "Child7BKey", "Child7")
Call .Add("Child5BKey", tvwChild, "Child8BKey", "Child8")
Call .Add(, tvwChild, "Root3Key", "Root3")
Call .Add("Root3Key", tvwChild, "Child1CKey", "Child1")
Call .Add("Root3Key", tvwChild, "Child2CKey", "Child2")
Call .Add("Root3Key", tvwChild, "Child3CKey", "Child3")
Call .Add("Root3Key", tvwChild, "Child4CKey", "Child4")
Call .Add("Root3Key", tvwChild, "Child5CKey", "Child5")
Call .Add("Child5CKey", tvwChild, "Child6CKey", "Child6")
Call .Add("Child5CKey", tvwChild, "Child7CKey", "Child7")
Call .Add("Child5CKey", tvwChild, "Child8CKey", "Child8")
End With
End Sub
Hi techman2553,
Thanks for your help. I appreciate it.
Ace