Context sensitive help in C# and CHM files

A good online help avoids support requests. Ideally, he gets the answer already in the help. So that the user does not have to search long, there is the possibility to navigate the user directly to the desired place, e.g. to the help of a certain dialog.

CHM files allow the definition of a help ID. This is a numeric value, e.g. 1000, which allows you to jump directly to a specific page. Each page can be assigned an ID. In this example we look at the whole thing with C#. The example project is also available for download at the end of this article.

Setting the ID for a page

First you have to assign the help ID for each page. This varies depending on the software. In our software DA-HelpCreator this is easily possible in the meta-settings to the page:

Here we enter the help ID:

We repeat this for each page we want to jump to. Then we create the CHM file.

Context-sensitive help in C#

In the example, we store the help file in the program directory. So in the same path as our .exe file.

We can determine the path to the help file with the following command:

String help = Path.Combine(new Uri(Path.GetDirectoryName
(Assembly.GetExecutingAssembly().CodeBase)).LocalPath, "help.chm");

“help.chm” is the file name of the help file. The rest looks a bit wild, but only determines the path to our program.

If we want to open the help file just like this, we can do this with the following command:


We simply start the CHM file here. This opens the file in the default view, as if we started it with a double click.

To jump to a page with ID we can use the following command:

Help.ShowHelp(this, help, HelpNavigator.TopicId, "1000");

The result is that the page with ID 1000 is opened:

This makes it easy to intercept the F1 key from a dialog and open the desired help page.


Creating a context sensitive help is a little hard work. The IDs have to be assigned and then only the opening of the help in the right place has to be implemented in the software.

Download the example

Leave a Reply

Your email address will not be published. Required fields are marked *