RichTextBox problem

  • Thread starter Thread starter Stuart Nathan
  • Start date Start date
S

Stuart Nathan

In VB - Visual Studio 2003
As I understand it,
in
the KeyDown event of a RichTextBox, I can put
If e.KeyCode = Keys.Return then e.Handled = False
and this will prevent the Enter key being added to the RichTextBox

but it doesn't - any ideas?
 
the KeyDown event of a RichTextBox, I can put
If e.KeyCode = Keys.Return then e.Handled = False
and this will prevent the Enter key being added to the RichTextBox

There is probably not an easy solution for the return key. Below is copied
from .net help:

"To handle keyboard events only at the form level and not allow other
controls to receive keyboard events, set the KeyPressEventArgs.Handled
property in your form's KeyPress event-handling method to true. Certain keys,
such as the TAB, RETURN, ESCAPE, and arrow keys are handled by controls
automatically. In order to have these keys raise the KeyDown event, you must
override the IsInputKey method in each control on your form. The code for the
override of the IsInputKey would need to determine if one of the special keys
is pressed and return a value of true."
 
Back
Top