When right-click on a textbox which has the default Windows contextmenu I want to know if the user selects copy
cut
or paste
option, to perform secondary operations when user has selected an specific contextmenu option.
I have no code 'cause I don't know where to start trying to recognize what option was selected by the user in the contextmenu, and how to capture that left click 'cause I've tried to capture the default contextmenu mouseleft click on the textbox MouseDown/Mouseclick
events without success, I know that has not much sense 'cause it is a contextmenu mouseclick, not a Textbox mouseclick, but well... I don't know how to manage that external contextmenu.
If someone need this, This is a modification of @BlueMonkMN code to work properly with the CUT option, and also added the DELETE option.
You can add a class like this to your project:
Then you can replace all occurrences of "TextBox" in the Designer.vb files with "MyTextBox". Then you will have access to 3 new events for Cut, Copy and Paste. You can handle them like this:
Notice how I've chosen to handle all 3 events in one function in this case, but you could handle them in separate functions as well. I noticed that the cut command seems to also cause a copy command event, but I will assume for now that you can deal with that slight complication.