HI all:
i want to ask how i can make ESC button active in form so when i press ESC in active form the form closed??
thanks
HI all:
i want to ask how i can make ESC button active in form so when i press ESC in active form the form closed??
thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Bechir BejaouiRank #144 · 15.9K reputationPosted Mar 21, 2008, 1:37 PM EDT
{
if (e.KeyCode == Keys.Escape)
this.Close();
}
Omar Mardini8 reputationPosted Mar 22, 2008, 2:55 PM EDT
Thank You but i've test it but nothing happen
pls help
AlanRank #669 · 3.6K reputationPosted Mar 22, 2008, 3:23 PM EDT
Bob Lewiston77 reputationPosted Mar 19, 2009, 10:03 AM EDT
Mirko Meier80 reputationPosted Mar 19, 2009, 10:42 AM EDT
Ryan AlfordRank #1,411 · 1.2K reputationPosted Mar 20, 2009, 8:15 AM EDT
private void button1_Click(object sender, EventArgs e){ this.Close();}then set the "CancelButton" property of the form to that button(it will be in the dropdown). The "CancelButton" is the button that will be fired when you hit the ESC button on the keyboard. So whatever code is in that click event will get run when you hit ESC.