How to: Provide Help in a Windows Application

You can make use of the HelpProvider component to attach Help topics within a Help file to specific controls on Windows Forms. The Help file can be either HTML or HTMLHelp 1.x or greater format.

Provide Help

  1. In Visual Studio, from the Toolbox, drag a HelpProvider component to your form.

    The component will reside in the tray at the bottom of the Windows Forms Designer.

  2. In the Properties window, set the HelpNamespace property to the .chm, .col, or .htm Help file.

  3. Select another control you have on your form, and in the Properties window, set the SetHelpKeyword property.

    This is the string passed through the HelpProvider component to your Help file to summon the appropriate Help topic.

  4. In the Properties window, set the SetHelpNavigator property to a value of the HelpNavigator enumeration.

    This determines the way in which the HelpKeyword property is passed to the Help system. The following table shows the possible settings and their descriptions.

    Member Name Description
    AssociateIndex Specifies that the index for a specified topic is performed in the specified URL.
    Find Specifies that the search page of a specified URL is displayed.
    Index Specifies that the index of a specified URL is displayed.
    KeywordIndex Specifies a keyword to search for and the action to take in the specified URL.
    TableOfContents Specifies that the table of contents of the HTML 1.0 Help file is displayed.
    Topic Specifies that the topic referenced by the specified URL is displayed.

At run time, pressing F1 when the control—for which you have set the HelpKeyword and HelpNavigator properties—has focus will open the Help file you associated with that HelpProvider component.

Currently, the HelpNamespace property supports Help files in the following three formats: HTMLHelp 1.x, HTMLHelp 2.0, and HTML. Thus, you can set the HelpNamespace property to an http:// address, such as a Web page. If this is done, it will open the default browser to the Web page with the string specified in the HelpKeyword property used as the anchor. The anchor is used to jump to a specific part of an HTML page.

Important

Be careful to check any information that is sent from a client before using it in your application. Malicious users might try to send or inject executable script, SQL statements, or other code. Before you display a user's input, store it in a database, or work with it, check that it does not contain potentially unsafe information. A typical way to check is to use a regular expression to look for keywords such as "SCRIPT" when you receive input from a user.

You can also use the HelpProvider component to show pop-up Help, even if you have it configured to display Help files for the controls on your Windows Forms. For more information, see How to: Display Pop-up Help.

See also