On Pressing Enter key

mmb

Active member
Joined
Aug 1, 2004
Messages
42
Programming Experience
1-3
I want On Pressing ENTER key in a Textbox1 , Button1 get Press.

pls Help
 

mzim

Well-known member
Joined
Jun 3, 2004
Messages
187
Location
Other side of the rock
Programming Experience
1-3
VB.NET:
 'set the keypreview to true
 'in the keypress event of the textbox
 if e.keycode = keys.enter then
    button1.performclick
 end if
 

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,524
Location
Lansing, MI; USA
Programming Experience
10+
actually i'd put it in the textbox's keyup event (in case the keypress event is programmed and doesnt allow an enter key, i do have several programs where that is the case) but yea

VB.NET:
private sub textbox_keyup (blah...blah) handles textbox.keyup
 if e.keycode = keys.enter then button1.performclick
 end sub
 
Top Bottom