Tab and Ctrl+I in a richtextbox

  • Thread starter Thread starter Fred
  • Start date Start date
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 ?
 
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 !!!
 
Back
Top