Results 1 to 4 of 4

Thread: Close window form when escape press

  1. #1

    Thread Starter
    Fanatic Member daimous's Avatar
    Join Date
    Aug 2005
    Posts
    657

    Close window form when escape press

    hi guys! help please. How can i close the window form when the user press the scape button?

  2. #2
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416

    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.

  3. #3

    Thread Starter
    Fanatic Member daimous's Avatar
    Join Date
    Aug 2005
    Posts
    657

    Re: Close window form when escape press

    Thaks for that but, i dont have the
    Code:
    e.Keycode property
    but i tried the Keychar but i have a problem comparing it becuase they have different types
    Code:
    e.Keychar
    is of type char and
    Code:
    Keys.Escape
    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.");
            }
    Attached Images Attached Images  

  4. #4
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416

    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
  •  



Click Here to Expand Forum to Full Width