Results 1 to 6 of 6

Thread: Using ESC Key............

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Posts
    278

    Using ESC Key............

    hi

    how can i use ESC key to unload form in a form with 10 or more textboxes and other controls too. the focus will be in textbox when the form get loaded


    saj

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Using ESC Key............

    To unload a Form with a command button in it (perhaps a Close/Exit button with an Unload Me in it) you could set its Cancel property to True so that when you press Esc it will be triggerred (it will execute the code bin its click event).
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Using ESC Key............

    if you have a command button to close the form, set it,s cancel property to true

    pete

  4. #4
    Fanatic Member
    Join Date
    Jan 2005
    Location
    In front of this pc.
    Posts
    580

    Re: Using ESC Key............

    You should be able to use the keydown event..not sure if the keycode here is correct but this will give you the idea anyway

    VB Code:
    1. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    2.     If KeyCode = VBEsc then
    3.         unload me
    4.     End If
    5. End Sub

    Edit---

    Ok, I'm slow AND behind the curve!

  5. #5
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Using ESC Key............

    anotherVBnewbie's idea would work too but you have to set the Form's KeyPreview = True.... I forgot the constant for the ESC...

    VB Code:
    1. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    2.     If KeyCode = 27 then
    3.         unload me
    4.     End If
    5. End Sub
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    May 2005
    Posts
    278

    Re: Using ESC Key............

    thnk u all,

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