Textbox click event or Return event

Posted by qcace on 29-Jan-2016 10:14

I have a textbox on a dotnet form and I am wanting to program an event when the Enter key is pressed.

The documentation states that the Click event is a higher level event that occurs when the Enter key is pressed, but this does not appear to be working.  I've also tried the Keypress event using the Lastkey function to see if I could read the Enter key being pressed but no luck.

Any help is appreciated....Thanks.

Posted by Lieven De Foor on 01-Feb-2016 04:48

If the documentation states that, than that's a documentation error, as the Click event has nothing to do with keyboard.

Just subscribe on the KeyDown event and check the KeyCode:

IF e:KeyCode:Equals(Keys:Enter) OR e:KeyCode:Equals(Keys:Return)

THEN /* Your code here... */

All Replies

Posted by Lieven De Foor on 01-Feb-2016 04:48

If the documentation states that, than that's a documentation error, as the Click event has nothing to do with keyboard.

Just subscribe on the KeyDown event and check the KeyCode:

IF e:KeyCode:Equals(Keys:Enter) OR e:KeyCode:Equals(Keys:Return)

THEN /* Your code here... */

Posted by qcace on 01-Feb-2016 11:46

"Unknown Field or Variable name - KEYS. (201)"

compile error when I try to compile this.  

Posted by Laura Stern on 01-Feb-2016 12:17

KEYS?  I don't see this in the example that was suggested.  Can you please show what line you are trying to compile.

Posted by Mike Fechner on 01-Feb-2016 12:22

Lieven mentioned the Keys Enum: Keys:Return.

Von Outlook Mobile gesendet




Posted by Laura Stern on 01-Feb-2016 12:34

Oh!  Got it.  You probably are missing the package name for the Keys enum - on the line or you need a USING statement.

Posted by qcace on 02-Feb-2016 08:41

Yes, thanks, I was missing a USING progress util statement at the top.

Posted by Lieven De Foor on 04-Feb-2016 04:11

I left that out as an exercise for the user ;-)

You were missing a USING System.Windows.Forms.Keys FROM ASSEMBLY.

This thread is closed