Leggi in inglese

Condividi tramite


Help Classe

Definizione

Viene incapsulato il modulo della Guida 1.0 HTML.

C#
public class Help
C#
public static class Help
Ereditarietà
Help

Esempio

Nell'esempio di codice seguente viene visualizzato un modulo contenente tre pulsanti che possono essere usati per interagire con il file della Guida Mspaint.chm. Il pulsante Mostra indice della Guida visualizza la scheda Indice per il file della Guida. Il pulsante Mostra guida visualizza il contenuto nel file della Guida in base al valore selezionato nell'elenco Strumento di navigazione della Guida . Il pulsante Mostra parola chiave visualizza il contenuto nel file della Guida in base alla parola chiave specificata nella casella di testo Parola chiave .

Ad esempio, per visualizzare la pagina Della Guida ovali in base al valore dell'indice, selezionare il HelpNavigator.KeywordIndex valore nell'elenco a discesa Strumento di navigazione della Guida , digitare ovali nella casella di testo Parametro e quindi fare clic sul pulsante Mostra guida . Per visualizzare l'argomento della Guida "Per disegnare con un pennello" in base alla parola chiave, digitare mspaint.chm::/paint_brush.htm nella casella di testo Parola chiave e quindi fare clic sul pulsante Mostra parola chiave .

Nell'esempio viene utilizzato il ShowHelp metodo per visualizzare le diverse schede della Guida e argomenti della Guida e il ShowHelpIndex metodo per visualizzare l'indice della Guida.

C#
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);
    }
}

Commenti

Non è possibile creare una nuova istanza della Help classe . Per fornire la Guida per un'applicazione, chiamare i metodi e ShowHelpIndex staticiShowHelp.

È possibile usare Help per visualizzare i file della Guida compilati (con estensione chm) o HTML nel formato della Guida HTML. I file della Guida compilati forniscono un sommario, un indice, funzionalità di ricerca e collegamenti di parole chiave nelle pagine. I collegamenti funzionano solo nei file della Guida compilati.

È possibile generare file della Guida HTML 1.x usando HTML Help Workshop. Per altre informazioni sulla Guida HTML, vedere "HTML Help Workshop" e altri argomenti della Guida HTML nella Guida html Microsoft.

Metodi

ShowHelp(Control, String)

Visualizza il contenuto del file della Guida all'URL specificato.

ShowHelp(Control, String, HelpNavigator)

Visualizza il contenuto del file della Guida all'URL specificato per un argomento specifico.

ShowHelp(Control, String, HelpNavigator, Object)

Visualizza il contenuto del file della Guida all'URL specificato fornito dall’utente.

ShowHelp(Control, String, String)

Visualizza il contenuto del file della Guida all'URL specificato per una parola chiave specifica.

ShowHelpIndex(Control, String)

Visualizza l'indice del file della Guida specificato.

ShowPopup(Control, String, Point)

Visualizza una finestra popup della Guida.

Si applica a

Prodotto Versioni
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
Windows Desktop 3.0, 3.1, 5, 6, 7

Vedi anche