Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Treeview basic question

Status
Not open for further replies.

MDA

Technical User
Jan 16, 2001
243
US
Hi all,

I have a treeview control on a form that has code like:
--------------
Dim nodX As Node
Set nodX = TreeView1.Nodes.Add(, , "AA", "Welcome")
Set nodX = TreeView1.Nodes.Add("AA", tvwChild, "C1", "Import Mapping")
Set nodX = TreeView1.Nodes.Add("C1", tvwChild, "C10", "Unit")
Set nodX = TreeView1.Nodes.Add("C1", tvwChild, "C11", "Account")
--------------
All I am trying to do is show a picture box based on the node chosen. For instance if the user clicks on the node "UNIT" which has key C10, then I want to show a specific picture box. I can't seem to figure out how to do this. I would like to use the CASE syntax to make this happen.

Any ideas are greatly appreciated.

Regards,

Mike
 
Here's a start. You can use this inside the Treeview1_dblclick event (add your own error checking)

Dim nodX As Node
Set nodX = TreeView1.Nodes(Treeview1.SelectedItem.Index)
select case nodX.key
case "C10": 'showpic
case "C11": 'showacct
end select

Or from the Treeview1_NodeClick event:


Private Sub Treeview1_NodeClick(ByVal TheNode As Node)
Select Case TheNode.Key
case "C10": 'showpic
case "C11": 'showact
End Select
End Sub


Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top