Solved

Issue with Tree view conrol

Posted on 2009-04-10
2
330 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

726 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