.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Reply
Message 1 of 4
cadcamm99
258 Views, 3 Replies

Enter Key

I cannot seem to trap the Enter key in a text box.  I there something I am doing wrong?

 

I tried the following:

 

Private Sub tbEdit_6_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles tbEdit_6.KeyPress
   If Asc(e.KeyChar) = 13 Then
       MsgBox("flag")
   End If
End Sub

 

also:


Private Sub tbEdit_6_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tbEdit_6.KeyDown
   If e.KeyData = Keys.Enter Then
       e.SuppressKeyPress = True
       MsgBox("flag")
   End If
End Sub

 

also:

 

Private Sub tbEdit_6_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tbEdit_6.KeyDown
   If e.KeyCode = Keys.Enter Then
       MsgBox("flag")
   End If
End Sub

3 REPLIES 3
Message 2 of 4
fieldguy
in reply to: cadcamm99

Is this a System.Windows.Forms.Textbox?  That tool has an "AcceptsReturn" property that defaults to "false".

Message 3 of 4
cadcamm99
in reply to: fieldguy

I set it to true and it still did not work.  I think there is something corrupted on my form.  I created a new form and put in new text fields and they worked fine with the enter key.  I didn't even have to set "AcceptsReturn true".

Message 4 of 4
leaveAlone
in reply to: cadcamm99

Shouldnt that be
If e.keycode = keys.enter
...

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost