Set focus on Sumit button when we press enter after entering text in text box

Posted on 2008-10-07
Last Modified: 2012-05-05
How do I Set focus on Sumit button when we press enter after entering text in text box
Question by:SGUDAPAT
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2

Expert Comment

ID: 22659213
This is form level property. I think there is AcceptButton property on the form. You can associate this with one of the buttons so when you press enter, it will actually fire click event of this button.

Author Comment

ID: 22659274
I tried setting the Focus-Enter-Property or event to the submit button, but it didn't work.
Is that is what you were referring if not, can you what exactly it is?
LVL 48

Expert Comment

ID: 22659356
Is this ASP.NET or Winforms ?
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Expert Comment

ID: 22659384
If you select the form in the design mode, Press F4 to view Form properties, you will find two properties:

1. AcceptButton
Gets/Sets the button on the form that is pressed when the user uses the enter key

2. CancelButton
Indicates the button control that is pressed when the user presses the ESC key

You can associate one of the buttons on the form, to these properties. Once you have associated these properties with respective buttons on the form, the button's event handlers will be invoked automatically when you press ENTER or ESC key.

So in your case assoicate Submit button with AcceptButton property of the form.

Author Comment

ID: 22659399
it is windows form in
LVL 48

Accepted Solution

jpaulino earned 125 total points
ID: 22659541

In the keydown event for the last textbox you can do something like this:
If e.KeyCode = Keys.Enter Then
End If

Author Closing Comment

ID: 31503831
thanks a bunch

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question