Tab and Ctrl+I in a richtextbox

F

Fred

Hello,

I program a user control which display a RichTextBox and a format
ToolStrip.
I want to process some shortcut keys.
The RichTextBox accepts tab.
Ctrl + I is supposed to format the selection in italic.
But Ctrl+I is also de code for Tab.
So when I press Ctrl+I, a tab is inserted (replacing the current
selection) AND the new selection is formatted in italic.

How can I do this ? Do I have to inherit first the standard RichTextBox
and override the OnKeyDown method ?
 
F

Fred

Dans : Fred disait :
Hello,

I program a user control which display a RichTextBox and a format
ToolStrip.
I want to process some shortcut keys.
The RichTextBox accepts tab.
Ctrl + I is supposed to format the selection in italic.
But Ctrl+I is also de code for Tab.
So when I press Ctrl+I, a tab is inserted (replacing the current
selection) AND the new selection is formatted in italic.

How can I do this ? Do I have to inherit first the standard
RichTextBox and override the OnKeyDown method ?

Of course not, just have to set the SuppressKeyPress property of the
KeyEventArgs parameter to false !!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top