Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making a button default so works when Enter btn pressed?

Status
Not open for further replies.

Ovatvvon

Programmer
Feb 1, 2001
1,514
US
I have little experience with VB.NET. Currently working in Visual Studio.NET. I recall that in VB6, you could set buttons to "default" and "cancel" so they would automatically work when the enter button or esc button was pressed.

Is there a way to do this in VB.NET? (I don't see it anywhere.)

-Ovatvvon :-Q
 
Nevermind, I found it too.. and I'll POST THE ANSWER

set the "acceptbutton" property on the form to the name of the button
 

You have to go to the properties window when the *form* is highlighted; then there is an option for "AcceptButton". There, you click on the dropdown list, and it will list all the buttons on the form. Select the one you want to be the default button when you hit the enter key.

Likewise, a little lower, is a dropdown option for "CancelButton", which selects a button when you hit the Esc key (generally used on the Exit button to end the program).

Hope this helps. :)



-Ovatvvon :-Q
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top