RichTextBox problem

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?
 
G

Guest

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."
 

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