Solved

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

Posted on 2011-02-24
4
614 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
  • 2
4 Comments
 
LVL 33

Accepted Solution

by:
jppinto earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Encryption Decryption in Oracle 12 107
As soon as i click a button on the form,it mnimises. 11 30
C# Single Form 8 28
Run a batch file when a Crystal Report is opened 5 15
This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now