surpress newline on Enter press

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
even if i catch the enter keypress, it still goes through...how can i stop it
from going through?
 
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.
 
Back
Top