Keyascii in a multiline textbox 
Author Message
 Keyascii in a multiline textbox

I have the following code in my keypress event so the user can move through
the form by pressing the "Enter" key.

Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress

If e.KeyChar = Chr(13) Then

    e.Handled = True ' Don't beep

    SendKeys.Send("{TAB}")

End If

End Sub

This works fine for every control I have on the form with the exception of
one.

I have a multiline textbox and I want the user to be able to press the
"Enter" key to move to a new line within the textbox instead of tabbing to
the next control.

Anybody have any suggestions on how I can use the above KeyPress for every
control except the multiline textbox?

Thanks,

JS



Thu, 22 Sep 2005 02:03:06 GMT  
 Keyascii in a multiline textbox
Hello,


Quote:
> I have a multiline textbox and I want the user to be
> able to press the "Enter" key to move to a new line
> within the textbox instead of tabbing to the next control.

\\\
Me.KeyPreview = True
.
.
.
Private Sub Form1_KeyDown( _
    ByVal sender As Object, _
    ByVal e As System.Windows.Forms.KeyEventArgs _
) Handles MyBase.KeyDown
    If e.KeyCode = Keys.Return Then
        If TypeOf Me.ActiveControl Is TextBoxBase Then
            If DirectCast(Me.ActiveControl, TextBoxBase).Multiline Then
                Return
            End If
        End If
        Me.SelectNextControl(Me.ActiveControl, True, True, True, True)
    End If
End Sub
///

Regards,
Herfried K. Wagner



Thu, 22 Sep 2005 03:41:36 GMT  
 Keyascii in a multiline textbox

Quote:
> I have the following code in my keypress event so the user can
> move through the form by pressing the "Enter" key.

> Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As
> System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress

> If e.KeyChar = Chr(13) Then

>     e.Handled = True ' Don't beep

>     SendKeys.Send("{TAB}")

Sendkeys is ugly. Use SelectNextControl instead.

Quote:
> End If

> End Sub

> This works fine for every control I have on the form with the
> exception of one.

> I have a multiline textbox and I want the user to be able to
> press the "Enter" key to move to a new line within the textbox
> instead of tabbing to the next control.

> Anybody have any suggestions on how I can use the above KeyPress
> for every control except the multiline textbox?

In Form1_Keypress, don't handle chr(13) when Activecontrol is the multiline
textbox.

--
Armin



Thu, 22 Sep 2005 02:36:04 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Keyascii 13 in a textbox ?

2. Newbie trying to print a multiline textbox

3. multiline textbox problem

4. Multiline Textbox Cause Page Overflows when Printing or doesn't print all lines

5. multiline textbox gives extra characters in Word

6. Textbox multiline

7. Multiline in textbox, ver. 2

8. Multiline in Textbox

9. Multiline textbox Scrollbars

10. Printing the contents of a multiline-textbox with pagebreaks

11. finding line number cursor is in multiline textbox

12. drag and drop into multiline textbox - HELP!!!!

 

 
Powered by phpBB® Forum Software