Search | Contact | Link To Us  

      VB .NET      

.NET Defined
OOP with VB
VB Language
Win Forms
Windows Controls
ADO .NET
User Controls
File Handling
Multithreading
Deployment
XML Web Services Essential XML
Resources
Discussions
ASP.NET
About



Advertisement


     HomeWindows Controls> HelpProvider 


HelpProvider 

Providing help with your application is very useful as it allows your users to understand it more easily, thereby increasing productivity and saving some money. Support for help in Visual Basic exists and you can display HTML files that can contain a set of linked topics.

Help Class

The Help class allows us to display HTML help to users. The Help class provides two methods: ShowHelp and ShowHelpIndex. ShowHelp is used to display a help file for a particular control and requires that control to be displayed along with the help file. The URL you specify for the help file can be in the form of C:\myHelp (local machine) or http:\\www.startvbdotnet.com\help.htm (Web). Generally, the Help class is used in conjunction with Menus, Context Menus.

Example

The following code displays a help file. This code assumes that you have a Button, Button1, Label, Label1 on the form and a help file named Apphelp.htm in the C: drive of your machine.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e_
As System.EventArgs) Handles Button1.Click
Help.ShowHelp(Label1, "C:\Apphelp.htm")
'using the Help class with label control
End Sub

The ShowHelpIndex method is used to display the index of a specified help file. You call the ShowHelpIndex method just like you call the ShowHelp method.

HelpProvider Component

HelpProviderComponent allows us to provide help for controls on the form when F1 key is pressed. The HelpProviderComponent is an extender provider which means that it coordinates and maintains properties for each control on the form. Notable Property of HelpProvider component is the HelpNameSpace property which specifies the URL for the help file associated with it.

The HelpProvider component provides three additional properties to each control on the form. These properties are:
HelpString: Determines the help string associated with a control.
HelpKeyWord: Determines the help keyword associated with a control.
HelpNavigator: Determines the kind of help associated with a control. Provides six values: TableOfContents, Find, Index, Topic, AssociatedIndex and KeywordIndex.

The above said three properties are visible in the properties window for each control once the HelpProvider component is added to the form. If the HelpNameSpace property is not set, the HelpString is automatically displayed, and other two properties are ignored.

Example

Drag two Buttons and the HelpProvider component onto the form. The following code displays a help string when Button2 has the focus and F1 key is pressed.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles MyBase.Load
HelpProvider1.SetHelpString(Button2, "I am supported by HelpProvider1")
'button2 needs to have focus to display this string when F1 is pressed
End Sub

The image below displays output from code above.

For Properties See: Control Object Properties - Form Properties

  Privacy Policy | Terms of Use | Site Map | Contact

  © 2004-2007 Startvbdotnet.com. All rights reserved.