0

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?

Anirudh Goel
  • 4,571
  • 19
  • 79
  • 109
  • "i've put it inside a panel control" Nothing to do with that. The event should fire regardless of where the control is. Are you sure the event is wired correctly? – Binary Worrier Mar 19 '09 at 17:45

1 Answers1

2

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
  • 50,774
  • 20
  • 136
  • 184
  • 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 Mar 19 '09 at 17:46
  • @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 Mar 19 '09 at 17:52
  • @anirudh: What TcKs said - would have been my answer pretty much :) – Binary Worrier Mar 19 '09 at 17:58
  • hi i can figure out what TcKs meant. It'd be great if i can find some sample code for it. – Anirudh Goel Mar 19 '09 at 18:02
  • http://www.ondotnet.com/pub/a/dotnet/2002/04/15/events.html is this link contains what you mean? – Anirudh Goel Mar 19 '09 at 18:09