This documentation is archived and is not being maintained.

Providing Help in a Windows Application

Visual Studio .NET 2003

Through the use of the HelpProvider component, you can attach Help topics within a Help file (that is either of HTML or HTMLHelp 1.x or greater format) to specific controls on Windows Forms.

To provide Help

  1. Drag a HelpProvider component from the Toolbox to your form.

    The component will sit 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 set the HelpKeyword property in the Properties window.

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

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

    This determines the fashion in which the HelpKeyword property is passed to the Help system. Below is a table of possible settings and their descriptions.

    Member NameDescription
    AssociateIndexSpecifies that the index for a specified topic is performed in the specified URL.
    FindSpecifies that the search page of a specified URL is displayed.
    IndexSpecifies that the index of a specified URL is displayed.
    KeywordIndexSpecifies a keyword to search for and the action to take in the specified URL.
    TableOfContentsSpecifies that the table of contents of the HTML 1.0 Help file is displayed.
    TopicSpecifies 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.

Note   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 (to jump to a specific part of an HTML page).
Security Note   Be careful to check any information that is sent from a client before using it in your application. Malicious users might try to send (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.

Be aware that 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 Displaying Pop-up Help.

See Also

Displaying Pop-up Help | Control Help Using ToolTips | Application Assistance | Windows Forms