Show Sitemap ..Help2HTMLHelpWinHelp
Home ..

Creating Pop-up Help for Visual Basic .NET controls

Windows Forms supports "What's this .." help on individual controls (Pop-up Help). The HELP button makes sense on dialog boxes, because modal dialog boxes need to be closed before focus can go to another window.

This help button 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 Pop-up 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 "hlpProvider1". This component gives every control on the form three new properties called HelpKeyword, HelpNavigator and HelpString on hlpProvider1.

Next step is to set the HelpString on hlpProvider1 property to the text you want display. You can do this by writing code, too.

Visual Basic Code

Public Class frmMain
  Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

  Public Sub New()
    MyBase.New()

    '--- This call is required for the Windows Form-Designer.
    InitializeComponent()

    '--- Add any initialization after the InitializeComponent() call
    Me.hlpProvider1.SetHelpString(Me.txtPopUp, "This is the text field. Enter some text.")
  End Sub

Save the text as new HelpString by setting the SetHelpString property:

  Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click
    Me.hlpProvider1.SetHelpString(Me.txtPopUp, Me.txtPopUp.Text)
  End Sub

Disable the Pop-Up message for this control by setting the SetShowHelp property:

  Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click
    Me.hlpProvider1.SetShowHelp(Me.txtPopUp, False)
  End Sub

Note:

The Windows Forms HelpProvider component is used to associate HTML Help files (HTMLHelp 1.x, Help 2.x or single HTML file) with your Windows application. The HelpString property can be used to show Pop-Up Help but you must set the HelpNamespace property of hlpProvider1 (see HTML Help). If there is no filename and the user hits F1 the application runs to an error.

 

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 ...