Processing "Control + C" keys in RichTextBox.KeyDown()

  • Follow


Hi there,

I'm using a RichTextBox to create a custom editor, my class inherits from 
it. I've set to false the property ShortcutsEnabled and I need to handle the 
combination of keys Control + C. I've tried it in many ways using the 
modifiers of the KeyEventArgs, using GetKeyboardState(), using GetKeyState() 
in the RichEdit KeyDown event but it doesn’t work.

I think the problem is that when the user press both keys the event is not 
fired for some reason, because if I check for the control key only it works 
and the same for the C key but when both are pressed it doesn’t work.

Can someone explain me why this is happening?
How can I handle these keys combination?

Thank you in advance,

Robe.

0
Reply Utf 11/19/2009 5:30:01 PM

Robe wrote:
> Hi there,
> 
> I'm using a RichTextBox to create a custom editor, my class inherits from 
> it. I've set to false the property ShortcutsEnabled and I need to handle the 
> combination of keys Control + C. I've tried it in many ways using the 
> modifiers of the KeyEventArgs, using GetKeyboardState(), using GetKeyState() 
> in the RichEdit KeyDown event but it doesn’t work.
> 
> I think the problem is that when the user press both keys the event is not 
> fired for some reason, because if I check for the control key only it works 
> and the same for the C key but when both are pressed it doesn’t work.
> 
> Can someone explain me why this is happening?
> How can I handle these keys combination?

The KeyEventArgs passed to your KeyDown event handler includes modifier 
key state.  So if you're having trouble, it's because your event handler 
isn't written correctly.

For more specific advice on in what way your event handler isn't written 
correctly, you will at a minimum need to post that event handler.  For 
best results, post a concise-but-complete code example that reliably 
demonstrates the problem.

Pete
0
Reply Peter 11/19/2009 6:25:16 PM


1 Replies
373 Views

(page loaded in 0.039 seconds)

Similiar Articles:










8/1/2012 2:40:42 PM


Reply: