I have a TextBox which has some default context menu and it works fine. For some “user friendly” approach I want to have same functionality of Cut/Copy/Paste in the main menu, but for that items I have just an event and I need to implement Cut/Copy/Paste functionality myself. Even if I do my best, I might not cover every possible case to keep my version and default context menu’s version of clipboard functionality identical.
First I tried to reach this context menu on my main menu event and fire context menu item’s event accordingly, but I TextBox.ContextMenu is null…
Any suggestions how to “link” main menu’s functionality to the default context menu’s functionality?
The TextBox class has Cut, Copy and Paste methods. When the user selects Cut, Copy or Paste from your menu, and your TextBox has focus, you can invoke the corresponding method of your TextBox.
MSDN has sample code:
http://msdn.microsoft.com/en-us/library/system.windows.forms.textboxbase.paste(v=VS.110).aspx