Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hey -

 

I was wondering how you can set a form so that when the user presses the 'ENTER' button, it will simulate them clicking a button on the form. For example, they input data into a textbox and hit enter instead of having to click the Submit buttom.

Thanks,

Tehon

  • *Experts*
Posted

Set the Form's AcceptButton property to a button control on the form.

 

This won't work when some controls have focus, such as a multi-line TextBox. But then, you wouldn't want Enter to press a button in that case :)

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted
There is no option on the form's properties for AcceptButton. I put frmExample. and the AcceptButton is not a property for it. Am I doing something wrong? The property is on the form and not the actual button right?

Thanks,

Tehon

  • *Gurus*
Posted
Set it in the designer. frmExample is the name of your form class, not an instance of the class itself so you won't be able to access any instance properties like that from code unless you actually have an instance to work with.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Posted

Where in the designer do I set it? I remember in VB 6 there was a default button for the form, but I do not see where I set it in the designer in VB .NET.

 

Thanks

Thanks,

Tehon

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...