Providing Help in a Windows Application
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
- 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.
- In the Properties window, set the HelpNamespace property to the .chm, col, or .htm Help file.
- 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.
- 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 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.
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.