Groups | Blog | Home
all groups > vb.net controls > may 2007 >

vb.net controls : catching RETURN in richtextbox


Michael Comperchio
5/4/2007 7:43:46 AM
I'm probably having a stupid attack, but I can't seem to find the mechanism
to capture the return key in a RTB. I have one in a dialog and instead of
entering a return in the RTB, the return key is triggering the default
button press.... I KNOW I'm missing something in the docs... But I've been
D**king with this for a while so it's time to break down and ... ask for
help...

Petar Atanasov
5/7/2007 4:37:27 PM
Hi, Michael,
Try this:

-----------------------------8<-------------------------------------------
Private Sub RichTextBox1_KeyDown(ByVal sender As System.Object,
ByVal e As System.Windows.Forms.KeyEventArgs)
Handles RichTextBox1.KeyDown
If e.KeyValue = 13 Then
Me.Text = "Enter pressed"
End If
End Sub
-----------------------------8<-------------------------------------------

HTH,
Petar Atanasov
http://a-wake.net

[quoted text, click to view]
AddThis Social Bookmark Button