?
Solved

How to Enable ESC to close a dialog box in VB.net

Posted on 2011-02-24
4
Medium Priority
?
644 Views
Last Modified: 2012-05-11
I'm converting an old app to VB.Net and have many dialog boxes.  How do you enable the ESC key to close a dialog box?
0
Comment
Question by:jackiemeck
[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
4 Comments
 
LVL 33

Accepted Solution

by:
jppinto earned 2000 total points
ID: 34974808
Set the Form properties

AcceptButton=your searchbutton
CancelButton=your cancelbutton
0
 
LVL 33

Expert Comment

by:jppinto
ID: 34974819
"Set the DIALOG Form properties..."
0
 
LVL 17

Expert Comment

by:nepaluz
ID: 34974935
you can also handle the keydown event to capture

    Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown

        If e.KeyCode = Keys.Escape Then Me.Close()
    End Sub

Open in new window

0
 

Author Comment

by:jackiemeck
ID: 34979696
I was unable to get the Subroutine to work (it appears sometimes my DataGridView captures the keypresses), but the AcceptButton/CancelButton solved my problem.  Thanks so much!!
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

764 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