Click here to Skip to main content
15,892,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am having a context menu displayed when i right click on a node of a treeview. Suppose my treeview is as follows

Root |->some.txt |-> Child(For some.txt) |-> Child1(child for Child)

If i right click on Child1 i will have an option as AddNew. If the user selects i will show a user control form for the user displayed in a panel.

What i need is if the user selects the option as Child1 and if the user control is active and when the user again right clicks
Posted
Comments
DavidKiryazi 8-Sep-10 7:36am    
I don't understand what that last sentance means, can you clarify?

seems like you need several different context menu's where a different menu is displayed depending on which tree node was under the mouse at the time the context menu was initiated.

Use the MouseDown event to alter the context menu's visible items. The event gets a MouseEventArgs parameter that contains X and Y coordinates.

You can use the Treeview.HitTest( Point ) method to get the node at the mouse's current location.

If that event isn't raised before the context menu is shown you could try "hot tracking" i.e. using the MouseMove event instead of MouseDown. It won't be very efficient because it will execute very often, but it will work.
 
Share this answer
 
If I got your questions right ... if you are looking for a way to control the context menu displayed for different nodes you can just assign the right context menu on the node

when you are populating the treeview control

TreeNode nd= TreeView1.Nodes.AddNode("Sometext.txt");
nd.ContextMenu=ContextMenu1;


other than that ... what you are looking for is a bit confusing may be with clarifications we can help you more.:confused::confused::confused::confused::confused::confused:
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900