Saturday, June 8, 2013

Close Windows Form Using Escape Key

Note : Keypreviw = True in Form Property

Then Write This Code in  KeyDown Event

private void Form1_KeyDown(object sender, KeyEventArgs e)
{
            if (e.KeyCode == Keys.Escape)
                this.Close();
}

No comments :

Post a Comment