HelpProvider


The HelpProvider component displays help for other controls. You can associate a HelpProvider with a control. Then, if the user sets focus to the control and presses the F1 key, the HelpProvider displays help for the control. The HelpProvider either displays a small tooltip-like pop-up displaying a help string, or it opens a help file.

To assign a help string to a control at design time, open the form in the form designer and select the control. In the Properties window, look for a property named HelpString on HelpProvider1, where HelpProvider1 is the name of your HelpProvider component. If the form contains more than one HelpProvider, the control should have more than one HelpString on property.

Enter the text you want the HelpProvider to display in this property and you’re finished. When the user sets focus to the control and presses F1, the HelpProvider displays the string automatically.

To set the help string programmatically, call the HelpProvider component’s SetHelpString method passing it the control and the help string that it should display for the control. The following code defines help strings for a series of address text box controls:

  HelpProvider1.SetHelpString(txtName, "Enter the customer's name.") HelpProvider1.SetHelpString(txtStreet, _     "Enter the customer's delivery street number and name, " & _     "plus any apartment or suite number.") HelpProvider1.SetHelpString(txtCity, "Enter the customer's delivery city.") HelpProvider1.SetHelpString(txtState, "Enter the customer's delivery state.") HelpProvider1.SetHelpString(txtZip, "Enter the customer's delivery ZIP code.") 

To provide help using a help file, set the HelpProvider component’s HelpNamespace property to the full name and path to the help file. Set the other control’s HelpNavigator on HelpProvider1 property to one of the values shown in the following table to tell the HelpProvider how to use the help file when the user asks for help on this control.

Open table as spreadsheet

HelpNavigator Value

Purpose

AssociateIndex

Opens the help file’s Index page and goes to the first entry that begins with the same letter as the control’s HelpKeyword on HelpProvider1 property.

Find

Opens the help file’s Index tab.

Index

Opens the help file’s Index tab and searches for the value entered in the control’s HelpKeyword on HelpProvider1 property.

KeywordIndex

Opens the help file’s Index tab and searches for the value entered in the control’s HelpKeyword on HelpProvider1 property.

TableOfContents

Opens the help file’s Table of Contents tab.

Topic

Displays the topic in the help file that has URL stored in the control’s HelpKeyword on HelpProvider1 property. For example, the URL street_name.htm might contain the help file’s page for the Street field.

To set a control’s HelpNavigator value in code, call the HelpProvider component’s SetHelpNavigator method passing it the control and the navigator method that you want to use. For example, the following code prepares to give help for the btnSetColor control. It sets the HelpProvider1 component’s help file to C:\Tools\littledraw.chm. It then sets the btnSetColor control’s HelpNavigator method to HelpNavigator.Topic. Finally, it sets the control’s HelpKeyword to select_color.htm. Now if the user sets focus to this control and presses F1, the HelpProvider opens the help file and displays the topic at select_color.htm.

  HelpProvider1.HelpNamespace = "C:\Tools\littledraw.chm" HelpProvider1.SetHelpNavigator(btnSetColor, HelpNavigator.Topic) HelpProvider1.SetHelpKeyword(btnSetColor, "select_color.htm") 

A control’s ShowHelp on HelpProvider1 property indicates whether the control should use the HelpProvider to display its help.




Visual Basic 2005 with  .NET 3.0 Programmer's Reference
Visual Basic 2005 with .NET 3.0 Programmer's Reference
ISBN: 470137053
EAN: N/A
Year: 2007
Pages: 417

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net