65.9K
CodeProject is changing. Read more.
Home

HelpButton: A Button Linked to a Topic of a chm Help File

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.75/5 (7 votes)

Mar 7, 2011

CPOL

2 min read

viewsIcon

18894

When clicked, this button shows the application help file and displays its topic page.

Introduction

A few months ago, my company asked me to add a help file to our application. And of course, they wanted the different sections to be easily reached by the user.

To reach the different sections from the main application, I thought that the classical question mark inside the title window bar (Form.HelpButton) would be enough but they wanted something easier for the real newbie. They told me that first clicking the help button, then clicking the control was not intuitive enough :(...

So I designed a very simple button: clicking that button would just display a topic from the help file. Nothing complicated there, but everybody was happy with that and it seems that the customers feedbacks were quite good as well.


screen_shot.JPG

So I thought maybe some of you could be interested even though there is nothing complicated there.

To make the help file, I used HTML Help Workshop. I created several topics with their IDs so I could reach them from code. The aim of this article is not to explain how to create help files, I will suppose that you already have one.

Using the Code

After referencing the Help.dll assembly, all you need is to initialize the chm file path (will be the same for every buttons):
Help.HelpButton.HelpFile = Application.StartupPath + "\\sample.chm";

Drop as many HelpButtons as you want inside your forms, and for each button set the Value property to the topic ID you want.

If you prefer to directly reference an HTML page or any of the HelpNavigator values, you may use the Style property of the button.

The last useful property is BigSize: you can choose whether you want a small (16x16) or large (32x32) icon for the question mark.

I hope some of you will find this control useful.