C# - 11 - Implementing a help file.

[C# 2.0]

If you have a help file for your application you probably want to access it from within your application. The System.Windows.Forms.Help assembly will do most of the work for you. However, be aware that the Help program opens modelly to the parent application window. This means that the help window must be closed before the user can continue. The solution is to create a dummy form that is modeless to the true parent and open the help window from there.

Assuming you have added the StringEnum helper module from Tip 10, add the following class to your application. Change the namespace (MyWindowsApplication) and the help file (xxxx.chm) appropriately.

This will give you 4 static methods to choose from that you can call from anywhere in your application.

ShowHelp.Contents() will open the help file and display the table of contents.

ShowHelp.Index() will open the help file and display the index.

ShowHelp.Search() will open the help file and display the search page.

The ForTopic() method will open the help file at a specific page. Each page you create in the help file will have a unique ID number, this method will convert a string enum into its appropriate string-based ID number. As you write the help file you will need to update the mapping in this routine accordingly. To implement this last add a public enum called HelpTopic …

So, for example, you can use ShowHelp.ForTopic(HelpTopic.LoginForm).

.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License