Results 1 to 2 of 2

Thread: KeyDown Event

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2002
    Location
    Canton, GA
    Posts
    487

    KeyDown Event

    What am I doing wrong?

    I want to enable a "help" form when a user presses F1.

    My Code:

    Code:
    Private Sub frmMain_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
            Dim HelpForm As New frmHelp()
            If e.KeyCode = Keys.F1 Then
                HelpForm.ShowDialog()
            End If
        End Sub
    What happens is if a user hits F1 then the form will show... BUT if the user hits [x] (form is closed) and you return to the main form and hit F1 - nothing happens...??

    Thanks..

    Anjari

  2. #2
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    Set the KeyPreview property of the main form to True.

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