Catching TAB in Windows Form

  • Thread starter Thread starter Marcin Waligora
  • Start date Start date
M

Marcin Waligora

Hi all,

I am trying tu use TAB button in my Windows Form in different way it is
usually intented (usually it jumps between controls). I want to catch while
it is in RichTextBox. I've checked OnKeyPressed, OnKeyDown, however they
never even receive the signal. Does anyone have any idea how to solve this
problem??

Any help is appreciated...
 
Is there any other way??
I don't want the RichTextBox to be Multiline.

Well, you could catch the enter keypress and ignore it, effectively making
it singleline although you could possibly paste a multiline string.
 
That's generally a problem. I can go with multiline, but I must catch enter
and tab, to prevent them from going into RichTextBox message. This is the
code I use to ignore the ENTER and TAB, but it doesn't work. Tab still moves
caret and enter moves it one line. Is there something wrong in this code??

I really appreciate your help.

private void keyDown(object sender, System.Windows.Forms.KeyEventArgs e){

if(e.KeyCode == Keys.Enter ){

e.Handled = true;}

if(e.KeyCode == Keys.Tab){

e.Handled=true;

}
 
I'm not sure why the enter gives you a new line as on my system it does
not.
However, I couldn't prevent TAB doing its default behaviour of adding \t.

You probably need to handle ProcessCmdKey in an inherited RichTextBox.
 
Set the AcceptsTab property on the RichTextBox to True.


Hi all,

I am trying tu use TAB button in my Windows Form in different way it is
usually intented (usually it jumps between controls). I want to catch while
it is in RichTextBox. I've checked OnKeyPressed, OnKeyDown, however they
never even receive the signal. Does anyone have any idea how to solve this
problem??

Any help is appreciated...

User submitted from AEWNET (http://www.aewnet.com/)
 
Back
Top