Question Treeview, context menu for certain nodes?

stealth

New member
Joined
May 20, 2009
Messages
1
Programming Experience
Beginner
For a project I am working on I am using treeview boxes to display a list of pupils they are sorted per year, then per class, and then you can select a pupil.

So for my question is it possible to make a contextmenustrip only work when you right click the class nodes.

Also is there a way to only display one year at time, so say for instance that I was looking for a class in the 3rd year, then all other year trees are closed, when i then press the 4th year the 3rd year closes?

And finally what is the answer to the forum question what is NINE plus ONE :)
I tried TEN and ten, but both are wrong :D

Thanks for any replies
 
For the first question, you cannot use the ContextMenuStrip property of the TreeView itself. You'd have to handle the MouseClick event of the control, perform a HitTest to determine whether you were on a node of interest and, if you were, call Show on your ContextMenuStrip.

For the second question, you'd need to handle the AfterSelect (or BeforeSelect) event and then manually call Collapse on all nodes that weren't in the current branch.
 
Back
Top