Click here to Skip to main content
15,070,233 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have the exit button to close the form but I also need to include the ESC key. How do I do that I have tried doing multiple things but I cant get it to work. Im using visual studio C#. Can someone please help me with this

What I have tried:

I have the exit button to close the form but I also need to include the ESC key. How do I do that I have tried doing multiple things but I cant get it to work. Im using visual studio C#. Can someone please help me with this
Posted
Updated 23-Feb-21 10:40am
v2
Comments
PIEBALDconsult 23-Feb-21 16:41pm
   
Is that what your users want? I dislike when something major closes when I press ESC.

1 solution

1) go to your form and view it in the UI view.
2) view the forms properties
3) set the Form's CancelButton property to your Cancel button. You won't need any code.

Now when you click the escape button the form will close.
   
Comments
Maciej Los 23-Feb-21 14:28pm
   
5ed!
slingding 23-Feb-21 20:03pm
   
Wow thanks!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900