Show Sitemap ..Help2HTMLHelpWinHelp
Home ..

Help for controls with VB .NET

 

Table of Contents

Creating Help for a form, a dialog or control with HTML files

Properties to display help (HTML file - local)
Properties to display help (HTML file - Server http://..)

Creating Help for a form, a dialog or control with local CHM file

Properties to display help (CHM file - local)
Show Table of Contents (TOC) tab and search related topic by keyword
Show Index and places on the first available keyword that starts with the letter.
Show Index tab and highlight keyword in keyword list
Show Search tab
Show Table of Contents (TOC) tab
Show Topic
HelpNavigator Enumeration

 

Help for controls

The Windows Forms supports a "What's this .." HelpButton and / or F1-Help on individual controls based on Help files. To attach Help topics within a Help file (that is either HTML or HTMLHelp 1.x/Help 2.x format) to specific controls on Windows Forms you need to use the HelpProvider component. The HelpProvider component will associates an HTMLHelp 1.x Help file (CHM) or a single HTML file with your Windows Form application.

The HelpButton will be located on the right side of the title bar and can be accessed through the HelpButton property. To include the Help Button on your form requires that the MinimizeBox and MaximizeBox property of the form (!) is set to "False" and the HelpButton to "True".

To provide this Help in your application, you have to use the HelpProvider control which you can find in the Toolbox on the Windows Forms tab. Drag and Drop a HelpProvider component from the Toolbox to your form. It is a component rather than a control, so when you put it on your form it will sit in the component tray below. Rename this component to "hlpHtmlLocal". This component gives every control on the form three new properties called HelpKeyword, HelpNavigator and HelpString on hlpProvider1.

If necessary (e.g. my example) drag and drop two more HelpProvider components to your form and rename them to "hlpProvider1" and "hlpHtmlServer".

 

Creating Help for a form, a dialog or control with HTML files

Properties to display help (HTML file - local )

Activate the hlpProvider component hlpHtmlLocal and set the HelpNameSpace property of hlpHtmlLocal to the file name you want to work with.

We open a local HTML file with the dialog using the little button to the right.

The next step is to set the HelpNavigator property of a control (e.g. button) to a value of the HelpNavigator enumeration (see table below). Here we use Topic.

When the application is running click the HelpButton to enable "What's this .." Help. The cursor changes. Now click the button or press F1 when the button has focus. This will open the single HTML file in your browser.

It seems you can't use anchor names to jump to a specific part of your HTML file.

Properties to display help (HTML file - Server http://..)

Activate the hlpProvider component and set the HelpNameSpace property of hlpHtmlServer to the file name you want to work with. Here we use a http:// address of a single HTML file. If you provide the file on your company server, you don't have to update the help file with the customer.

The next step is to set the HelpNavigator property of a control (e.g. button) to a value of the HelpNavigator enumaration (see table below). Here we use Topic. Then we set the HelpKeyword on hlpHtmlSever property to e.g. "anchor3". Don't add a leading "#". Leave it empty if you want to open a HTML file without anchors. The Help Handles cmdControl2.Click Dim sHelpFile As String Dim sStartupPath As String '--- Initialize context-sensitive help --- Keyword property provides the key information to retrieve the help associated with the control.

When the application is running click the HelpButton to enable "What's this .." Help. The cursor changes. Now click the button or press F1 when the button has focus. This will open the single HTML file over the Internet in your browser.

Creating Help for a form, a dialog or control with local CHM file

Properties to display help (CHM file - local)

Activate the hlpProvider component and set the HelpNameSpace property of hlpProvider1 to the file name you want to work with. Here we use a CHM file. CHM files are a compressed ITStorage format that is used by Microsoft's HTMLHelp Workshop.

 

  Private Sub cmdControl2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
  Handles cmdControl2.Click
    Dim sHelpFile As String
    Dim sStartupPath As String
    '--- Initialize context-sensitive help ---
    sStartupPath = Application.StartupPath.ToString
    sHelpFile = Replace(sStartupPath, "\bin", "\hlp") & "\VBnetCHM.chm"
    Me.hlpProvider1.HelpNamespace = sHelpFile
    Me.hlpProvider1.SetHelpNavigator(Me.cmdControl1, HelpNavigator.KeywordIndex)
    Me.hlpProvider1.SetHelpKeyword(Me.cmdControl1, "Help topic of control 1")
  End Sub

 

Show Table of Contents (TOC) tab and search related topic by keyword

Set the HelpNavigator property of a control (e.g. a button) to a value of the HelpNavigator enumaration (see table below).

To get following results from the example, press F1 key when the button has focus or click the HelpButton and then click the corresponding button:

 

Note: The call is dependent on the last open tab (Contents or Index) before closing the CHM window.

 

 

Show Index and places on the first available keyword that starts with the letter.

Set the HelpNavigator property of a control (e.g. a button) to a value of the HelpNavigator enumaration (see table below).

To get following results from the example, press F1 key when the button has focus or click the HelpButton and then click the corresponding button:

 

Please notice further technical information.

 

Show Index tab and highlight keyword in keyword list

Set the HelpNavigator property of a control (e.g. a button) to a value of the HelpNavigator enumaration (see table below).

To get following results from the example, press F1 key when the button has focus or click the HelpButton and then click the corresponding button:

 

Note: Click "Show" ("Anzeigen") to view the topic in the contents pane.

 

Show Search tab

Set the HelpNavigator property of a control (e.g. a button) to a value of the HelpNavigator enumaration (see table below).

To get following results from the example, press F1 key when the button has focus or click the HelpButton and then click the corresponding button:

 

Show Table of Contents (TOC) tab

Set the HelpNavigator property of a control (e.g. a button) to a value of the HelpNavigator enumaration (see table below).

To get following results from the example, press F1 key when the button has focus or click the HelpButton and then click the corresponding button.

 

Show Topic

Set the HelpNavigator property of a control (e.g. a button) to a value of the HelpNavigator enumaration (see table below).

 

To get following results from the example, press F1 key when the button has focus or click the HelpButton and then click the corresponding button.

 

HelpNavigator Enumeration

The HelpNavigator property is an enumeration that specifies the Help command to use when retrieving Help from the Help file for the specified control.

HelpNavigator Property
Description
AssociateIndex Shows the index and places on the first available keyword that starts with the letter. The letter is deduced from the first letter of the word in the HelpKeyword property.
Find Show Search tab.
Something (?) is necessary in the HelpKeyword property!
Index Show the index and place on the keyword. The keyword is indicated in the HelpKeyword property.
KeywordIndex Show Table of Contents (TOC) , places on the topic and shows the related topic in the contents pane. The topic is searched with the keyword which is indicated in the HelpKeyword property.
TableOfContents Specifies that the table of contents (TOC) of the HTML 1.0 Help file is displayed.
HelpKeyword property detail not necessary!
Topic Specifies that the topic referenced by the specified URL is displayed.
TopicId This value becomes availably only with .NET 2.0.

 

Download Example

Unfortunately, you don't have Visual Studio .NET but you have installed the Microsoft .NET Framework 1.0 (e.g. from your CD-Version of Windows XP SP1) unzip the example for Visual Basic 2002 and double-click the file VBnetCHM.exe.

 

Top ...