views:

1892

answers:

1

I have made a custom control which consists of a richtextbox and a picture box. Now i want to include a contextmenustrip on the richtextbox actually. But the code which i want to call on click of the different menus on the menustrip belongs to the Main project in which i'l be adding this control. So i thought of adding the contextmenustrip to the usercontrol in the project. But now problem is if i right click on the picture box i get the menu strip but when i rightclick on the richtextbox i don't get contextmenustrip, any reasons or suggestions?

Also strangely any event which i write for handling the usercontrol in my project it doesn't at all fire. Is it because i've put it inside a panel control? Any help?

+2  A: 

Add the context menu to the rich text box, as you did initially. Now, instead of executing the code, raise an event when then menu item is clicked.

Handle this new event in the main project.

Binary Worrier
can you elaborate as what u mean by raising the event when menu item is clicked? Do you mean i must fully write the menu, and for each menu item raise the event click?
Anirudh Goel
@Anirudh: You can do for every menu item one event or one event for every menu item with the menu item passed in derived EvetArgs class as argument.
TcKs
@anirudh: What TcKs said - would have been my answer pretty much :)
Binary Worrier
hi i can figure out what TcKs meant. It'd be great if i can find some sample code for it.
Anirudh Goel
http://www.ondotnet.com/pub/a/dotnet/2002/04/15/events.html is this link contains what you mean?
Anirudh Goel