Subject: associate keyboard return to a button
Posted By: silvia Post Date: 2/10/2006 3:52:51 AM
hi once more time to everybody! i have a form with a button called Aceptar. I would like that pressing the return key on my keyboard it would make the same effect than clicking with the mouse on the button. does anybody know how to do this??? thank you!

silvi

Reply By: planoie Reply Date: 2/11/2006 12:24:03 PM
What kind of application are you in? Winforms? Webforms?

-Peter
Reply By: silvia Reply Date: 2/13/2006 3:15:33 AM
winform, peter

Reply By: planoie Reply Date: 2/13/2006 9:36:24 PM
You should be able to handle a keypress event for the form or whatever control is on the form and catch the enter key code, then you can just call the button click() handler method.

-Peter
Reply By: yamyam Reply Date: 2/14/2006 7:21:51 AM
Alternatively can you just not set the DialogResult property of the button to "OK".  If I understand correctly, setting this property will make that button the default "ACCEPT" button for the form and pressing ENTER will be equivalent to clicking on it.

ciao,
yamyam
Reply By: silvia Reply Date: 2/16/2006 4:03:12 AM
i tried the thing about "dialogresult", but i think it is for something different to what i want to do, because nothing happens

now i have to investigate about keypress, because i've never use it.

thank you for the advices

Reply By: yamyam Reply Date: 2/17/2006 7:43:07 AM
If you are looking at trapping keyboard events, look at key-down and key-up instead of keypress event as keypress event does not trap all key presses.
Reply By: MAKO Reply Date: 2/28/2006 11:44:04 AM
The NotifyDefault method of a button takes a boolean value to draw itself as the default button and you can also use the AcceptButton property of the form to the default button.

:-Q Marvin B-)
Reply By: MarkMHChen Reply Date: 2/28/2006 4:06:24 PM
How about set the AcceptButton property of the form to the button Aceptr? Is that what you want?

Mark Chen

Go to topic 38729

Return to index page 356
Return to index page 355
Return to index page 354
Return to index page 353
Return to index page 352
Return to index page 351
Return to index page 350
Return to index page 349
Return to index page 348
Return to index page 347