?
Solved

Windows Forms -- Default button

Posted on 2003-03-04
2
Medium Priority
?
322 Views
Last Modified: 2012-05-04
Is there a way to set a button on a form to be the default button when the user presses the enter key? That is, without having to capture the key press event on the form?
0
Comment
Question by:tpatten
[X]
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
2 Comments
 
LVL 28

Accepted Solution

by:
iboutchkine earned 120 total points
ID: 8064858
On Form property use AcceptButton ptoperty

In the designer you can set the forms AcceptButton property to your
button. AcceptButton is when you hit return.

There's also a CancelButton which is when you hit Cancel.

 From codebehind this will look like:

     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As_
      System.EventArgs) Handles MyBase.Load

         Me.AcceptButton = YourAcceptButton
         Me.CancelButton = YourCancelButton

     End Sub
0
 
LVL 1

Author Comment

by:tpatten
ID: 8064905
See -- that was easy! Thanks.
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
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…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

800 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