Pressing "Enter" whilst in a text box event

MikeyLDS

Freshman
Joined
Aug 25, 2004
Messages
35
Er, this may be a simple question that I'm about to ask ... But what event is fired when you press the Enter key after typing in a text box.

I'm trying to fire a particular even with the user either pressing bttnSend or by simply hitting "Enter"
 
Use the textbox's KeyUp event and test to see if its the enter key that has been pressed. Example:
Visual Basic:
Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp
        If (e.KeyData = Keys.Enter) Then MsgBox("Congratulations, you pressed enter!")
End Sub
 
Back
Top