Home All Groups Group Topic Archive Search About

surpress newline on Enter press

Author
2 Aug 2006 4:09 PM
iwdu15
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
--
-iwdu15

Author
2 Aug 2006 4:52 PM
ag
Capture the KeyChar of Enter i.e. 13 and call some other method on
KeyDown event
Author
2 Aug 2006 8:41 PM
iwdu15
even if i catch the enter keypress, it still goes through...how can i stop it
from going through?
--
-iwdu15
Author
3 Aug 2006 4:22 AM
ShaneO
iwdu15 wrote:
> 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.