How can I cover the menu item's shortcut?
Supposed I have a form with KeyPreview=true and a menu item whose shortcut is CTRL+C. Add a Textbox on the form. When I select some text in the Textbox and press CTRL+C, the selected text just can not be copied because system just call the menu item's OnClick event handler.
And then how can I copy the selected text via CTRL+C, that is to say, how can I cover the menu item's shortcut Onclick event handler in some particular situations?
Your idea and suggestion will be highly appreciated. Thanks!
[515 byte] By [
TomChen] at [2008-3-1]
Hi,
I guess this is not a very good practice. It seems that overiding a system keystroke on a form totaly replaces it. So I suggest don't use system keystrokes as shortcuts on your menu. If you don't want you textbox to be affected by the shortcuts, you could set the ShortcutsEnabled property to false...
cheers,
Paul June A. Domag
Hi,
I know how it feels like. But you could have a work around. In your menuitem_click event check first if the this.ActiveControl is a textbox. If it is then don't execute. In your textbox, handle the keydown event and catch the ctrl+c keystroke. Manually copy the selected text in the clipboard...
I know its a little bit lousy, but that's all I can come up with...
cheers,
Paul June A. Domag