[program-l] Really Sweet ContextHelp in VB.net

  • From: "RicksPlace" <ofbgmail@xxxxxxxxx>
  • To: <program-l@xxxxxxxxxxxxx>
  • Date: Sat, 20 Oct 2012 05:07:27 -0400

Hi Guys:
First, the MS HTML Help WorkShop seems accessible so far but...
I dont need any html to use context sensitive help in a vb.net application so 
I will start with a really simple Context Help System to avoid the html for now:
later I will develop some html pages and play with the WorkShop to see if it is 
fully accessible.The below article I left intact so just jump to Rt02 for the 
step by step I will use to create context sensitive help.
In short:
Drop a HelpProvider on the form and some new properties will be made available 
for each control on the form in the Properties Window, one of them being the 
HelpString property.
Now, either just type in some value into the HelpString in the Properties 
Window or,
Create a string in your code:
Dim SomeText As String = "Hello World, I am a button"
and then assign the string to the button1 element in the Form's Load Event:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles MyBase.Load
HelpProvider1.SetHelpString(GetDataButton, "I am supported by HelpProvider1")
'GetDataButton needs to have focus to display this string when F1 is pressed
End Sub
This method does not require any html pages so it is the easiest method and the 
one I will use first!
Again skip the short method explained first by jumping to RtHere02 if you want.

RtHere01
Windows 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.
RtHere02
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
EndOfFile

Other related posts:

  • » [program-l] Really Sweet ContextHelp in VB.net - RicksPlace