Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
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
 
Old February 10th, 2006, 04:52 AM
Authorized User
 
Join Date: Jan 2006
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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

 
Old February 11th, 2006, 01:24 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

What kind of application are you in? Winforms? Webforms?

-Peter
 
Old February 13th, 2006, 04:15 AM
Authorized User
 
Join Date: Jan 2006
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

winform, peter :)

 
Old February 13th, 2006, 10:36 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

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

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
 
Old February 16th, 2006, 05:03 AM
Authorized User
 
Join Date: Jan 2006
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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 :)

 
Old February 17th, 2006, 08:43 AM
Registered User
 
Join Date: Feb 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.
 
Old February 28th, 2006, 12:44 PM
Authorized User
 
Join Date: Feb 2006
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to MAKO
Default

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-)
 
Old February 28th, 2006, 05:06 PM
Registered User
 
Join Date: Feb 2006
Posts: 4
Thanks: 0
Thanked 1 Time in 1 Post
Default

How about set the AcceptButton property of the form to the button Aceptr? Is that what you want?

Mark Chen





Similar Threads
Thread Thread Starter Forum Replies Last Post
Associate a combobox with a textbox OMEGA ADO.NET 0 August 3rd, 2007 05:01 AM
Associate script with a folder... MaX. VBScript 0 October 15th, 2004 01:26 PM
Associate "Find" command on form grahampinkney Access 3 August 23rd, 2004 05:51 AM
return to exact location like the 'back' button dhaywirex Classic ASP Basics 4 February 21st, 2004 02:08 AM
How to reference keyboard press to visual button ? Necromancer26 C# 2 September 29th, 2003 03:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.