469,888 Members | 1,236 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,888 developers. It's quick & easy.

How do I make a Button "active" for the Enter Key?

I'm something of a rookie at .Net. I know I can set TabIndex for
controls in a GroupBox, and tab my way over to a button so it's
"Active" and will be clicked by hitting the Enter key.

But isn't there some way of setting it to the same state? I've built
a very simple login for a tabpage in a tab control, so you enter a
name and password and click the "login" button, which queries a
database to validate you. someone told me it's "correct" programming
to make it so that the user only has to complete his entry of name
and password and then immediately hit Enter and the button should be
in the active state for that without having to do one more tab-over.

I looked in the All Members in the online Help and couldn't see what I
wanted.

Thanks

Nov 20 '05 #1
3 3449
Hi,

Set the forms acceptbutton to the button you want to be clicked when
you press enter.

Ken
--------------------
"felecha" <fe*******@yahoo-dot-com.no-spam.invalid> wrote in message
news:40**********@127.0.0.1...
I'm something of a rookie at .Net. I know I can set TabIndex for
controls in a GroupBox, and tab my way over to a button so it's
"Active" and will be clicked by hitting the Enter key.

But isn't there some way of setting it to the same state? I've built
a very simple login for a tabpage in a tab control, so you enter a
name and password and click the "login" button, which queries a
database to validate you. someone told me it's "correct" programming
to make it so that the user only has to complete his entry of name
and password and then immediately hit Enter and the button should be
in the active state for that without having to do one more tab-over.

I looked in the All Members in the online Help and couldn't see what I
wanted.

Thanks

Nov 20 '05 #2
* fe*******@yahoo-dot-com.no-spam.invalid (felecha) scripsit:
I'm something of a rookie at .Net. I know I can set TabIndex for
controls in a GroupBox, and tab my way over to a button so it's
"Active" and will be clicked by hitting the Enter key.

But isn't there some way of setting it to the same state? I've built
a very simple login for a tabpage in a tab control, so you enter a
name and password and click the "login" button, which queries a
database to validate you. someone told me it's "correct" programming
to make it so that the user only has to complete his entry of name
and password and then immediately hit Enter and the button should be
in the active state for that without having to do one more tab-over.


Assign the button to the form's 'AcceptButton' property.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #3
Form.AcceptButton works just great and it was easy to understand how
to use it.

I was looking and looking but if what you're looking for is not there
but somewhere else ...

Thanks to all, this is a big help

F

Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Philippe Poulard | last post: by
reply views Thread by Matteo Gelosa | last post: by
9 posts views Thread by Patrick | last post: by
reply views Thread by Kevin White | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.