CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2002
    Posts
    47

    Form KeyPress event

    Hi

    i would like to let the user close the form by pressing the escape button.

    I tried to edit the keyPress event of the form, but that doesn't work...nothing append.

    To do that ... do i have to edit the keypress event for each of the controls that are in my form ?

    Thanks for your help
    Alexandre

  2. #2
    Join Date
    Nov 2002
    Location
    Tatooine
    Posts
    155
    If you have an exit button, you could set the form's CancelButton property to it. The CancelButton is called automatically when the user presses the Escape Key.

    Or you can trap for the Escape Key in the KeyUp or KeyDown events. I can't rember for sure, but I think these events will fire for the Escape key while the KeyPress event won't??

    Hope this helps.
    That which does not kill us, only makes us stronger.

    MCSD .NET

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

Featured