 |
| C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

February 10th, 2006, 04:52 AM
|
|
Authorized User
|
|
Join Date: Jan 2006
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
associate keyboard return to a button
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
|
|

February 11th, 2006, 01:24 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
What kind of application are you in? Winforms? Webforms?
- Peter
|
|

February 13th, 2006, 04:15 AM
|
|
Authorized User
|
|
Join Date: Jan 2006
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
winform, peter :)
|
|

February 13th, 2006, 10:36 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
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
|
|

February 14th, 2006, 08:21 AM
|
|
Registered User
|
|
Join Date: Feb 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

February 16th, 2006, 05:03 AM
|
|
Authorized User
|
|
Join Date: Jan 2006
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
i tried the thing about "dialogresult", but i think it is for something different to what i want to do, because nothing happens :D
now i have to investigate about keypress, because i've never use it.
thank you for the advices :)
|
|

February 17th, 2006, 08:43 AM
|
|
Registered User
|
|
Join Date: Feb 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

February 28th, 2006, 12:44 PM
|
|
Authorized User
|
|
Join Date: Feb 2006
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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-)
|
|

February 28th, 2006, 05:06 PM
|
|
Registered User
|
|
Join Date: Feb 2006
Posts: 4
Thanks: 0
Thanked 1 Time in 1 Post
|
|
How about set the AcceptButton property of the form to the button Aceptr? Is that what you want?
Mark Chen
|
|
 |