Microsoft .NET

How to Use HTML Help .CHM Files in a .NET Application

The .NET development environment is stocked with native support for HTML Help, which means that you can integrate a .CHM help file to your C# or VB.NET application by using built-in methods without the need to use HTML Help API functions directly.

Use the .NET's "Help" Class to Control Your Help File from the Code

The Help class available in the .Net environment provides method that you can use to integrate and control a CHM help file from your application. Below are code examples of most frequent actions:

Show a Specific Help Topic Using Its Context Number

This method will open the specified CHM help file (YourHelpFile.chm) and display the requested topic with the context number equals to 50.

Help.ShowHelp(this, "YourHelpFile.chm", HelpNavigator.TopicId, 50);

Show the Table of Contents

This method is mostly used if you simply need to open your CHM file without going to a help topic, so the user will see the Table of Contents tab and the default topic on the right side.

Help.ShowHelp(this, "YourHelpFile.chm", HelpNavigator.TableOfContents, "");

Show the Index Tab

Similarly to the previous method, you can open your CHM help file and display the Index tab.

Help.ShowHelp(this, "YourHelpFile.chm", HelpNavigator.Index, "");

Using the HelpProvider Class

The HelpProvider class allows you to add context-sensitive Help for buttons, text field, and other controls. Thus, you can perform a specific action when the user focuses a control and press the F1 key, or selects the control using the help button from the window's caption bar.

To use this functionality:

  1. Add a HelpProvider component to the form and specify the HelpProvider.HelpNamespace property that should contain the location to your CHM help file.
  2. Add the help button to the window's caption bar by enabling the form's HelpButton property. You may also need to disable the MaximizeBox, and MinimizeBox properties of the form.
  3. Finally, setup the HelpKeyword, HelpNavigator, HelpString, and ShowHelp properties for the controls that you want to provide context sensitive help form.

It should be pointed out that the value of the HelpKeyword property depends on a specific action you want to perform. For example, if you want a control to show a help topic (when clicking F1 on it), you can set the HelpNavigator property to TopicId, and the HelpKeyword property to the Context Number that should be called.

Related Links

You can also visit the links below for information on using a CHM file in other development tools.

Download a Help Authoring Tool

You can download one of the recommendable help authoring tools that combines a rich feature-set, slight learning curve, and affordable price.

HelpSmith Download

HelpSmith main window

Product Details:

Detail Value
Product HelpSmith 7.3
Filename HelpSmithSetup.exe
File size 40 MB
Platform Windows 10/8/7/Vista/XP
System requirements 1 GHz processor, 512MB RAM, 150MB free disk space