jackiemeck
asked on
How to Enable ESC to close a dialog box in VB.net
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
"Set the DIALOG Form properties..."
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
ASKER
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!!