When a ContextMenuStrip is open with, say, an option for Copy – if the user presses C – Copy is selected.
How can this be prevented?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If setting the
KeyPressEventArgs.Handledfield doesn’t do the trick, you may need to catch thePreviewKeyDownevent and change the event to not be an input key (PreviewKeyDownEventArgs.IsInputKey = false) to prevent it from ever getting treated as a regular KeyDown/KeyUp/KeyPress.See http://msdn.microsoft.com/en-us/library/vstudio/system.windows.forms.control.previewkeydown(v=vs.110).aspx for further details.
Note: you’ll also have to move all your KeyPress-handling code into PreviewKeyDown, because you’ll stop getting the KeyPress event when you set IsInputKey to false.