Jmjl3
asked on
TreeView Control
I need help with the TreeView control! I need to know how to add Root items and child and parent items etc, and if an item is selected to display something in a label or whatever. I've looked at the MSDN article on the TreeView control, but that didn't help at all.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have a problem with the code Bobeo gave me.
Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
Label1 = Node
End Sub
That doesen't work. I get an error saying:
"Compile Error:
User-defined type not defined"
And it highlights
Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node
Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
Label1 = Node
End Sub
That doesen't work. I get an error saying:
"Compile Error:
User-defined type not defined"
And it highlights
Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node
Give this a try as a starter?
Dim XNode As Node
Private Sub Form_Load()
'set up treeview properties
TreeView1.Style = tvwTreelinesPlusMinusPictu
TreeView1.LineStyle = tvwRootLines
'add root nodes
Set XNode = TreeView1.Nodes.Add(, , "Root1", "Root1")
Set XNode = TreeView1.Nodes.Add(, , "Root2", "Root2")
Set XNode = TreeView1.Nodes.Add(, , "Root3", "Root3")
'add child nodes
Set XNode = TreeView1.Nodes.Add("Root1
Set XNode = TreeView1.Nodes.Add("Root1
Set XNode = TreeView1.Nodes.Add("Root1
Set XNode = TreeView1.Nodes.Add("Root2
Set XNode = TreeView1.Nodes.Add("Root2
Set XNode = TreeView1.Nodes.Add("Root2
Set XNode = TreeView1.Nodes.Add("Root3
Set XNode = TreeView1.Nodes.Add("Root3
Set XNode = TreeView1.Nodes.Add("Root3
End Sub
Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
Label1 = Node
End Sub
Hope it helps
Bobeo