Export (0) Print
Expand All
0 out of 1 rated this helpful - Rate this topic

Help Class

Encapsulates the HTML Help 1.0 engine.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

public class Help
public class Help
public class Help

You cannot create a new instance of the Help class. To provide Help for an application, call the static ShowHelp and ShowHelpIndex methods.

You can use Help to show compiled Help files (.chm) or HTML files in the HTML Help format. Compiled Help files provide table of contents, index, search, and keyword links in pages. Shortcuts work only in compiled Help files.

You can generate HTML Help 1.x files with the HTML Help Workshop. For more information on HTML Help, see "HTML Help Workshop" and other HTML Help topics at http://msdn.microsoft.com.

The following code example displays a form with three buttons that can be used to interact with the mspaint.chm Help file. The Show Help Index button displays the Index tab for the Help file. The Show Help button displays content in the Help file based on the value selected in the Help Navigator list. The Show Keyword button displays content in the Help file based on the keyword specified in the Keyword text box.

For example, to show the Ovals Help page by the index value, select the HelpNavigator.KeywordIndex value in the Help Navigator drop-down list, type ovals in the Parameter text box, and then click the Show Help button. To show the “To paint with a brush” Help topic by the keyword, type mspaint.chm::/paint_brush.htm in the Keyword text box, and then click the Show Keyword button.

The example uses the ShowHelp method to display the different Help tabs and Help topics, and the ShowHelpIndex method to display the Help index.

using System;
using System.Drawing;
using System.ComponentModel;
using System.Windows.Forms;

public class Form1 : System.Windows.Forms.Form
{
    private const string helpfile = "mspaint.chm";
    private System.Windows.Forms.Button showIndex;
    private System.Windows.Forms.Button showHelp;
    private System.Windows.Forms.Label label1;
    private System.Windows.Forms.ComboBox navigatorCombo;
    private System.Windows.Forms.Button showKeyword;
    private System.Windows.Forms.TextBox keyword;
    private System.Windows.Forms.Label label2;
    private System.Windows.Forms.Label label3;
    private System.Windows.Forms.TextBox parameterTextBox;

    [STAThread]
    static void Main() 
    {
        Application.Run(new Form1());
    }

    public Form1()
    {
        this.showIndex = new System.Windows.Forms.Button();
        this.showHelp = new System.Windows.Forms.Button();
        this.navigatorCombo = new System.Windows.Forms.ComboBox();
        this.label1 = new System.Windows.Forms.Label();
        this.showKeyword = new System.Windows.Forms.Button();
        this.keyword = new System.Windows.Forms.TextBox();
        this.label2 = new System.Windows.Forms.Label();
        this.label3 = new System.Windows.Forms.Label();
        this.parameterTextBox = new System.Windows.Forms.TextBox();

        // Help Navigator Label
        this.label1.Location = new System.Drawing.Point(112, 64);
        this.label1.Size = new System.Drawing.Size(168, 16);
        this.label1.Text = "Help Navigator:";

        // Keyword Label
        this.label2.Location = new System.Drawing.Point(120, 184);
        this.label2.Size = new System.Drawing.Size(100, 16);
        this.label2.Text = "Keyword:";

        // Parameter Label
        this.label3.Location = new System.Drawing.Point(112, 120);
        this.label3.Size = new System.Drawing.Size(168, 16);
        this.label3.Text = "Parameter:";

        // Show Index Button
        this.showIndex.Location = new System.Drawing.Point(16, 16);
        this.showIndex.Size = new System.Drawing.Size(264, 32);
        this.showIndex.TabIndex = 0;
        this.showIndex.Text = "Show Help Index";
        this.showIndex.Click += new System.EventHandler(this.showIndex_Click);

        // Show Help Button
        this.showHelp.Location = new System.Drawing.Point(16, 80);
        this.showHelp.Size = new System.Drawing.Size(80, 80);
        this.showHelp.TabIndex = 1;
        this.showHelp.Text = "Show Help";
        this.showHelp.Click += new System.EventHandler(this.showHelp_Click);

        // Show Keyword Button
        this.showKeyword.Location = new System.Drawing.Point(16, 192);
        this.showKeyword.Size = new System.Drawing.Size(88, 32);
        this.showKeyword.TabIndex = 4;
        this.showKeyword.Text = "Show Keyword";
        this.showKeyword.Click += new System.EventHandler(this.showKeyword_Click);

        // Help Navigator ComboBox
        this.navigatorCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
        this.navigatorCombo.Location = new System.Drawing.Point(112, 80);
        this.navigatorCombo.Size = new System.Drawing.Size(168, 21);
        this.navigatorCombo.TabIndex = 2;

        // Keyword TextBox
        this.keyword.Location = new System.Drawing.Point(120, 200);
        this.keyword.Size = new System.Drawing.Size(160, 20);
        this.keyword.TabIndex = 5;
        this.keyword.Text = "";

        // Parameter TextBox
        this.parameterTextBox.Location = new System.Drawing.Point(112, 136);
        this.parameterTextBox.Size = new System.Drawing.Size(168, 20);
        this.parameterTextBox.TabIndex = 8;
        this.parameterTextBox.Text = "";

        // Set up how the form should be displayed and add the controls to the form.
        this.ClientSize = new System.Drawing.Size(292, 266);
        this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                        this.parameterTextBox, this.label3,
                                        this.label2, this.keyword,
                                        this.showKeyword, this.label1,
                                        this.navigatorCombo, this.showHelp,
                                        this.showIndex});
        this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
        this.Text = "Help App";

        // Load the various values of the HelpNavigator enumeration
        // into the combo box.
        TypeConverter converter;
        converter = TypeDescriptor.GetConverter(typeof(HelpNavigator));
        foreach(object value in converter.GetStandardValues()) 
        {
            navigatorCombo.Items.Add(value);
        }
    }

    private void showIndex_Click(object sender, System.EventArgs e)
    {
        // Display the index for the help file.
        Help.ShowHelpIndex(this, helpfile);
    }
    private void showHelp_Click(object sender, System.EventArgs e)
    {
        // Display Help using the Help navigator enumeration
        // that is selected in the combo box. Some enumeration
        // values make use of an extra parameter, which can
        // be passed in through the Parameter text box.
        HelpNavigator navigator = HelpNavigator.TableOfContents;
        if (navigatorCombo.SelectedItem != null)
        {
            navigator = (HelpNavigator)navigatorCombo.SelectedItem;
        }
        Help.ShowHelp(this, helpfile, navigator, parameterTextBox.Text);
    }
    private void showKeyword_Click(object sender, System.EventArgs e)
    {
        // Display help using the provided keyword.
        Help.ShowHelp(this, helpfile, keyword.Text);
    }
}

import System.*;
import System.Drawing.*;
import System.ComponentModel.*;
import System.Windows.Forms.*;
import System.Collection.*;
import System.Collections.*;

public class Form1 extends System.Windows.Forms.Form
{
    private String helpfile = "mspaint.chm";
    private System.Windows.Forms.Button showIndex;
    private System.Windows.Forms.Button showHelp;
    private System.Windows.Forms.Label label1;
    private System.Windows.Forms.ComboBox navigatorCombo;
    private System.Windows.Forms.Button showKeyword;
    private System.Windows.Forms.TextBox keyword;
    private System.Windows.Forms.Label label2;
    private System.Windows.Forms.Label label3;
    private System.Windows.Forms.TextBox parameterTextBox;

    /** @attribute STAThread()
     */
    public static void main(String[] args)
    {
        Application.Run(new Form1());
    } //main

    public Form1()
    {
        this.showIndex = new System.Windows.Forms.Button();
        this.showHelp = new System.Windows.Forms.Button();
        this.navigatorCombo = new System.Windows.Forms.ComboBox();
        this.label1 = new System.Windows.Forms.Label();
        this.showKeyword = new System.Windows.Forms.Button();
        this.keyword = new System.Windows.Forms.TextBox();
        this.label2 = new System.Windows.Forms.Label();
        this.label3 = new System.Windows.Forms.Label();
        this.parameterTextBox = new System.Windows.Forms.TextBox();
        // Help Navigator Label
        this.label1.set_Location(new System.Drawing.Point(112, 64));
        this.label1.set_Size(new System.Drawing.Size(168, 16));
        this.label1.set_Text("Help Navigator:");
        // Keyword Label
        this.label2.set_Location(new System.Drawing.Point(120, 184));
        this.label2.set_Size(new System.Drawing.Size(100, 16));
        this.label2.set_Text("Keyword:");
        // Parameter Label
        this.label3.set_Location(new System.Drawing.Point(112, 120));
        this.label3.set_Size(new System.Drawing.Size(168, 16));
        this.label3.set_Text("Parameter:");
        // Show Index Button
        this.showIndex.set_Location(new System.Drawing.Point(16, 16));
        this.showIndex.set_Size(new System.Drawing.Size(264, 32));
        this.showIndex.set_TabIndex(0);
        this.showIndex.set_Text("Show Help Index");
        this.showIndex.add_Click(new System.EventHandler(
            this.showIndex_Click));
        // Show Help Button
        this.showHelp.set_Location(new System.Drawing.Point(16, 80));
        this.showHelp.set_Size(new System.Drawing.Size(80, 80));
        this.showHelp.set_TabIndex(1);
        this.showHelp.set_Text("Show Help");
        this.showHelp.add_Click(new System.EventHandler(this.showHelp_Click));
        // Show Keyword Button
        this.showKeyword.set_Location(new System.Drawing.Point(16, 192));
        this.showKeyword.set_Size(new System.Drawing.Size(88, 32));
        this.showKeyword.set_TabIndex(4);
        this.showKeyword.set_Text("Show Keyword");
        this.showKeyword.add_Click(new System.EventHandler(
            this.showKeyword_Click));
        // Help Navigator ComboBox
        this.navigatorCombo.set_DropDownStyle(
            System.Windows.Forms.ComboBoxStyle.DropDownList);
        this.navigatorCombo.set_Location(new System.Drawing.Point(112, 80));
        this.navigatorCombo.set_Size(new System.Drawing.Size(168, 21));
        this.navigatorCombo.set_TabIndex(2);
        // Keyword TextBox
        this.keyword.set_Location(new System.Drawing.Point(120, 200));
        this.keyword.set_Size(new System.Drawing.Size(160, 20));
        this.keyword.set_TabIndex(5);
        this.keyword.set_Text("");
        // Parameter TextBox
        this.parameterTextBox.set_Location(new System.Drawing.Point(112, 136));
        this.parameterTextBox.set_Size(new System.Drawing.Size(168, 20));
        this.parameterTextBox.set_TabIndex(8);
        this.parameterTextBox.set_Text("");
        // Set up how the form should be displayed and add the controls 
        // to the form.
        this.set_ClientSize(new System.Drawing.Size(292, 266));
        this.get_Controls().AddRange(new System.Windows.Forms.Control[] { 
            this.parameterTextBox, this.label3, this.label2, this.keyword, 
            this.showKeyword, this.label1, this.navigatorCombo, this.showHelp, 
            this.showIndex });
        this.set_FormBorderStyle(
            System.Windows.Forms.FormBorderStyle.FixedDialog);
        this.set_Text("Help App");
        // Load the various values of the HelpNavigator enumeration
        // into the combo box.
        TypeConverter converter;
        converter = TypeDescriptor.GetConverter(HelpNavigator.class.ToType());
        IEnumerator myEnum = converter.GetStandardValues().GetEnumerator();
        while (myEnum.MoveNext()) {
            Object value = myEnum.get_Current();
            navigatorCombo.get_Items().Add(value);
        }
    } //Form1
    
    private void showIndex_Click(Object sender, System.EventArgs e)
    {
        // Display the index for the help file.
        Help.ShowHelpIndex(this, helpfile);
    } //showIndex_Click

    private void showHelp_Click(Object sender, System.EventArgs e)
    {
        // Display Help using the Help navigator enumeration
        // that is selected in the combo box. Some enumeration
        // values make use of an extra parameter, which can
        // be passed in through the Parameter text box.
        HelpNavigator navigator = HelpNavigator.TableOfContents;
        if (navigatorCombo.get_SelectedItem() != null) {
            navigator = (HelpNavigator) navigatorCombo.get_SelectedItem();
        }
        Help.ShowHelp(this, helpfile, navigator, parameterTextBox.get_Text());
    } //showHelp_Click

    private void showKeyword_Click(Object sender, System.EventArgs e)
    {
        // Display help using the provided keyword.
        Help.ShowHelp(this, helpfile, keyword.get_Text());
    } //showKeyword_Click
} //Form1 

System.Object
  System.Windows.Forms.Help
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.