Click here to Skip to main content
15,867,686 members
Articles / Programming Languages / C#
Tip/Trick

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

Rate me:
Please Sign up or sign in to vote.
4.75/5 (7 votes)
8 Mar 2011CPOL2 min read 17.3K   8   8
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):
C#
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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
France France
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Questionthank you. Pin
datdit27-Oct-14 4:25
datdit27-Oct-14 4:25 
GeneralMean instead of application path we have to set the director... Pin
demouser7437-Mar-11 21:48
demouser7437-Mar-11 21:48 
GeneralRe: Yes. When you deploy your application, if the user selects f... Pin
Olivier Levrey7-Mar-11 21:57
Olivier Levrey7-Mar-11 21:57 
GeneralGood one i tested your code it's working fine Pin
demouser7437-Mar-11 21:43
demouser7437-Mar-11 21:43 
GeneralWill that CHM will be opened if i have it any where accordin... Pin
demouser7437-Mar-11 21:39
demouser7437-Mar-11 21:39 
GeneralRe: "all you need is to initialize the chm file path". It means:... Pin
Olivier Levrey7-Mar-11 21:42
Olivier Levrey7-Mar-11 21:42 
GeneralThis will search for the Help File if it is in Application d... Pin
demouser7437-Mar-11 17:36
demouser7437-Mar-11 17:36 
GeneralRe: This line of code was just an example. You can of course put... Pin
Olivier Levrey7-Mar-11 21:35
Olivier Levrey7-Mar-11 21:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.