Solved

Issue with Tree view conrol

Posted on 2009-04-10
2
325 Views
Last Modified: 2013-12-17
Hi,
I want to use context menu in TreeView control. I implemented a event method for OnMouseClick and then checking if the button was right clicked. if the button is right mouse button i am displaying a message box. This is done just for tesing.
This works fine if i have some nodes in tree view control and right click on some node. But if there are no nodes in the tree view and if i do a right click, the event is not being handled!!! Can you please tell me how to solve this issue.
I am Implementing the tree view so that if i right click on the tree view, i should get a context menu. from the context menu, i should be able to add, remove, rename the nodes and sub-nodes. Since currently no nodes are present the event is not at all handled and i am unable to display the context menu.
Please help me solving this issue.

Thanks
0
Comment
Question by:yamurthy
2 Comments
 
LVL 2

Accepted Solution

by:
T0ni earned 250 total points
ID: 24114557
Hi yamurthy,

If the treeview is empty with absolutely no treenodes, then I think this should be the way to go:
1) Create a contextMenuStrip
2) From the treeview's property grid set the ContextMenuStrip property to the contextMenuStrip that you have just created.

Now when ever you click on the treeview the context menu will appear.
ContextMenuStrip.jpg
0
 
LVL 1

Author Closing Comment

by:yamurthy
ID: 31568840
Initially i did check for contextMenustrip in the treeview properties. but did not add the strip from the tool box!!!. was just looking in the properties and was wondering that it was just (none) and nothing else. :)
Thanks a lot for the answer
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now