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

  • Thread starter Thread starter felecha
  • Start date Start date
F

felecha

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
 
Hi,

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

Ken
 
* (e-mail address removed)-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.
 
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
 
Back
Top