surpress newline on Enter press

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • iwdu15

    #1

    surpress newline on Enter press

    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
  • ag

    #2
    Re: surpress newline on Enter press

    Capture the KeyChar of Enter i.e. 13 and call some other method on
    KeyDown event

    Comment

    • iwdu15

      #3
      Re: surpress newline on Enter press

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

      Comment

      • ShaneO

        #4
        Re: surpress newline on Enter press

        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_Ke yDown(ByVal sender As Object, ByVal e As
        System.Windows. Forms.KeyEventA rgs) Handles RichTextBox1.Ke yDown

        If e.KeyCode = Keys.Return Then
        e.SuppressKeyPr ess = 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.

        Comment

        Working...