I currently have a C# winforms app with Ctrl+C and Ctrl+V bound as keyboard shortcuts on the Edit main menu. There is some custom copy/paste behaviour inside code which responds to these menu items, such as copying and pasting rows in listviews.
However, my problem is that you can edit text inside a row, and when you do so, I want Ctrl+C and Ctrl+V to not trigger the edit menu command and should rather default to the normal text based copy/paste.
One thing I tried is triggering BeforeLabelEdit and AfterLabelEdit events, and manually disabling/re-enabling the menu items from inside there. Unfortunately, it seems that a keyboard shortcut on a disabled menu item still triggers the menu_Popup event, which is currently used to decide which menu items should be enabled/disabled. (For example, "Paste" is only active if there is text on the clipboard). So even if I disable the menu item, the keyboard shortcut will still activate the Popup event, which will re-enable the menu item. (Is this a bug?)
I can't find any method of temporarily disabling a menu items keyboard shortcut without manually storing the old shortcut, setting the shortcut to null, then copying it back when I need to re-enable (which feels dirty).
Surely overriding the copy/paste behaviour, or adding to it, is a common thing to want to do? Is there a better pattern to use here?