This simple tutorial will guide you, how to use a CHM help file with your Microsoft Visual C# projects or even small applications. To use a CHM help manual for your application, you need to first create a CHM help file for your project. After Creating your CHM file, you need to link it thorough your C# application. Let me show you how you can open it from your C# application.
Assuming that you all know how to start a new project on visual studio, I skip all those steps. As you can see above there is simple windows application contains only a single button. Now to open a CHM file by clicking on the “View Help Topics” Button, you have to write a single line code only. Double click on the “View Help Topics” Button and write the code below inside the scope of Button1_Click function.
System.Diagnostics.Process.Start (Application.StartupPath + "\\Help Document.chm");
After writing this code it will look like this
private void button1_Click(object sender, RoutedEventArgs e)
{
System.Diagnostics.Process.Start(Application.StartupPath + \\Help Document.chm);
}
Make sure your CHM file is in your application folder. Now Debug your application and test it. You can also open any other file or application using the code above through your C# application. Hope you find it helpful. Please feel free to ask anything and do comment.
Thanks for the help... :)
ReplyDeleteRajeev
thanks from Colombia =)
ReplyDeleteWhat does the StartupPath refer to? When I copy pasted the above code into my application, the StartupPath has error.
ReplyDeleteThe same directory that the exe is running from.
ReplyDeleteA bit improved (in order to avoid an unhandled exception if the help file does not exist) + you should use Path.Combine():
ReplyDeletestring helpFileName = System.IO.Path.Combine(Application.StartupPath, "Xxxx.chm");
if (System.IO.File.Exists(helpFileName))
System.Diagnostics.Process.Start(helpFileName);
so cool !!
ReplyDeleteThank you for this topic
ReplyDeleteNice dude... It's works @hfrmobile.
ReplyDeleteHey guys sorry was stuck in other activities so cant reply to you people. Well I am glad it is helpful for you guys. I am looking forward to post on stuff related to VS 2010 and other upcoming technologies. Once again I appreciate all of you to take interest in the post.
ReplyDeleteThank you very much...
ReplyDeleteThank you!
ReplyDeleteThanks it really works
ReplyDeleteThanks alot
ReplyDeleteGrazie, effective and to the point.
ReplyDeleteThanks a lot! We used this in our school project :)
ReplyDeleteHow do you open the chm file to a particular topic ID?
ReplyDelete[C#] public static void ShowHelp(Control, string);
ReplyDeleteSystem.Windows.Forms.Help.ShowHelp(this, Application.StartupPath + "\\XXXXX.chm");