Home > Basic Functions > Context-sensitive Help > Windows Applications > Windows F1 Application Help

Windows F1 Application Help

You can add context sensitive help to your Windows application so that when a user presses the F1 key, the help system is displayed. Follow the steps below to add F1 context sensitivity to your Visual Studio 2003/2005 Windows application.

1. Open your Visual Studio Windows application.


2. Set the 'KeyPreview' property for the form to 'True'

3. Double click the form to open the code window.



4. Select 'KeyDown' from the 'Events' list

5. Add the following code to the "Sub Form2_Keydown" event:

Open a Dynamic Help System
Private Sub Form2_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
    If e.KeyCode = 112 Then
        Help.ShowHelp(Me, "http://www.domain.com/HelpConsole 2010 Help")
    End If
End Sub


Open a Static Help System
Private Sub Form2_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
    If e.KeyCode = 112 Then
        Help.ShowHelp(Me, "help\default.htm")
    End If
End Sub
* the url above assumes that the help system is in a sub folder named 'help'


ShowHelp Syntax:    Help.ShowHelp(Parent, URL)
Parent - Reference to the current form
URL - The url of the help system



6. Press F5 to run the application. Press F1 to open the help system.





See also
URL Parameters
Windows Application Help Button
Windows Form Help Button
Windows Field Help Button
Windows F1 Form Help
Windows F1 Field Help