surpress newline on Enter press

G

Guest

hi, i have a control that inherits from RichTextBox. What i want to be able
to do is surpress the Enter key inserting a newline into the text. For
instance, in AIM when you press Enter, it doesnt insert a new line, it sends
the message. Thats the kind of thing i want to be able to do. How can i do
this?

thanks
 
G

Guest

even if i catch the enter keypress, it still goes through...how can i stop it
from going through?
 
S

ShaneO

iwdu15 said:
hi, i have a control that inherits from RichTextBox. What i want to be able
to do is surpress the Enter key inserting a newline into the text. For
instance, in AIM when you press Enter, it doesnt insert a new line, it sends
the message. Thats the kind of thing i want to be able to do. How can i do
this?

thanks

I believe this is what you want (Watch for line-wrapping) -

Private Sub RichTextBox1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles RichTextBox1.KeyDown

If e.KeyCode = Keys.Return Then
e.SuppressKeyPress = True
'The "Return/Enter Key" is now absorbed
'Now do something else here.....
End If

End Sub


ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.
 

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