|
-
Jun 8th, 2007, 05:56 PM
#1
Thread Starter
Fanatic Member
Close window form when escape press
hi guys! help please. How can i close the window form when the user press the scape button?
-
Jun 8th, 2007, 10:44 PM
#2
Re: Close window form when escape press
In the keydown event of your form.
if(e.keycode == Keys.Escape) this.Close();
and set the keypreview property of the form to true.
-
Jun 9th, 2007, 07:29 PM
#3
Thread Starter
Fanatic Member
Re: Close window form when escape press
Thaks for that but, i dont have the but i tried the Keychar but i have a problem comparing it becuase they have different types is of type char and is of type keys. I've tried parsing them but i have no luck...help please
Code:
private void FrmSearch_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == Keys.Escape)
MessageBox.Show("you press escape.");
}
-
Jun 9th, 2007, 08:04 PM
#4
Re: Close window form when escape press
keydown event not keypress.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|