Saturday, May 16, 2015

How to close winforms by pressing escape key

STEP 1

First Set KeyPreview Property True in Form

STEP 2

Now Create One Keydown event of Form

STEP 3

Write Below Code in Keydown Event

if (e.KeyCode == Keys.Escape)
{
     this.Close();
}

No comments :

Post a Comment