Developing the connection between the Windows .NET application and the help file
The final stage is to establish the connection between forms and form controls of a Windows .NET application with the help file and individual help topics. This is done with Visual Studio or the Visual Studio Express products to set the appropriate properties of the forms and to connect the Help button with Visual Basic or C# code. In the case of Ferrysoft Help Desk Administrator, Visual Basic is used as the source code language.
The image below shows Visual Basic Express with the Main form open.

The Windows Forms HelpProvider component is used to associate a help file with the application. Therefore a HelpProvider needs to be added to each form as follows:
- Open the form in Design View.
- Drag a HelpProvider control from the All Windows Forms Toolbox to the form. When it is added to the form, the HelpProvider component appears in the tray at the bottom of the Windows Forms Designer.
- Set the properties of the HelpProvider in the properties window. In the case of Ferrysoft Help Desk Administrator, the only property that needs setting is HelpNamespace which is set to the name of the help file, that is Administrator.chm.
If the name of the HelpProvider has been left as HelpProvider1 then each control of the form that can provide help, including the form itself will now have these properties:
- HelpKeyword on HelpProvider1
- HelpNavigator on HelpProvider1
- HelpString on HelpProvider1
- ShowHelp on HelpProvider1
In order to connect a form to its corresponding help topic, each control of the form and the form itself must have properties set as follows:
- Set HelpKeyword on HelpProvider1 to the name of the HTML topic file, in this case Main.htm.
- Set HelpNavigator on HelpProvider1 to Topic.
- HelpString on HelpProvider1 can be left blank.
- Set ShowHelp on HelpProvider1 to True.
This is sufficient to complete the connection of the form to the help file so that when the user presses the F1 key, the help file will open at the appropriate topic.
If a Help button is required on the form to do the same thing then the following additional steps are necessary:
- Open the form in Design View.
- Drag a Button control from the All Windows Forms Toolbox to the form.
- Set the properties of the Button in the properties window, for example, Name to cmdHelp and Text to Help.
- Connect the Click action of the Button control using the code that follows.
Visual Basic
Private Sub cmdHelp_Click( _
ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles cmdHelp.Click
System.Windows.Forms.Help.ShowHelp( _
Me, _
HelpProvider1.HelpNamespace, _
System.Windows.Forms.HelpNavigator.Topic, _
HelpProvider1.GetHelpKeyword(Me))
End Sub
The image below shows Ferrysoft Help Desk Administrator with the Main window open.

If the user presses the Help button or presses the F1 key while the focus is anywhere on the window then HTML Help opens and displays the help file to the user.
The image below shows HTML Help with the Main window help topic open.

Conclusion
Using HTML Help Workshop and Visual Studio or the Visual Studio Express products, it is possible to quickly develop on-line help that will enhance the usability of a Windows .NET application.