Simple treeview question

I have built a treeview with several nodes.......however.

I now want to assign separate events to each of the nodes, I have already coded the actual events but how do you declare an individual node as a sub procedure.


Within the treeview one of my nodes  looks like this....

Set nodX = TreeView1.Nodes.Add("r", tvwChild, "c1", "Load")

So, how do I assign a NodeClick event to this individual node


Private Sub............................................................


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You don't, you use the NodeClick event and check the value of the Node parameter. You can use something like this

Select Case Node.Key
Case "c1"
  'Put code that is to happen when the user press the node with key c1 here
  'or you could call a procedure if you want to make it easier to read
Case somethingelse
Case somethingelse
End Select

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
You cannot assign a seperate event to each Node. You have to use the events provided.

You could probably subclass the treeview , but then its no longer a "Simple Treeview Question"

The NodeClick event passes a reference to the Node that was clicked so use a
Select Case, to handle the different nodes.

Use the Tag property to hold an extra id data, remember in the Common Controls that come with VB6 can have objects in the Tag property.

Matt_UnsworthAuthor Commented:

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.