Esta documentación está archivada y no tiene mantenimiento.

HelpProvider (Clase)

Proporciona Ayuda emergente o en pantalla para los controles.

Espacio de nombres: System.Windows.Forms
Ensamblado: System.Windows.Forms (en system.windows.forms.dll)

public class HelpProvider : Component, IExtenderProvider
public class HelpProvider extends Component implements IExtenderProvider
public class HelpProvider extends Component implements IExtenderProvider
No aplicable.

Cada instancia de HelpProvider mantiene una colección de referencias a los controles asociados a ella. Para asociar un archivo de ayuda al objeto HelpProvider, establezca la propiedad HelpNamespace. Para especificar el tipo de ayuda que se desea proporcionar, llame al método SetHelpNavigator y asigne un valor de HelpNavigator al control especificado. Para proporcionar la palabra clave o tema de la ayuda, llame al método SetHelpKeyword. Para abrir la ayuda sobre un tema concreto, la palabra clave se debe pasar en el formulario topicName.htm.

Para asociar una cadena de Ayuda específica a un control, utilice el método SetHelpString. La cadena que se asocia a un control utilizando este método se muestra en una ventana emergente cuando el usuario presiona la tecla F1 mientras el control tiene el foco.

Si no se ha establecido la propiedad HelpNamespace, se debe utilizar el método SetHelpString para proporcionar el texto de ayuda. Si ha establecido tanto la propiedad HelpNamespace como el texto de Ayuda, tendrá prioridad la Ayuda de la propiedad HelpNamespace.

El control HelpProvider llama a los métodos de la clase Help para proporcionar la funcionalidad de ayuda.

En el ejemplo de código siguiente se muestra la forma de utilizar la clase HelpProvider para mostrar la ayuda contextual en un formulario que contiene cuatro campos de dirección. En el ejemplo se utiliza el método SetHelpString para establecer el texto de información sobre herramientas de la ayuda. Cuando se utiliza el botón de ayuda contextual y se hace clic con el cursor de ayuda sobre un campo de dirección, aparece la información sobre herramientas de la ayuda con el texto especificado. Cuando se presiona la tecla F1 con el foco en un campo de dirección, se muestra el archivo de ayuda mspaint.chm porque la propiedad HelpNamespace se ha establecido en mspaint.chm. Se llama al método SetShowHelp con cada control de dirección para indicar que tiene el contenido de la ayuda disponible.

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

public class Form1 : System.Windows.Forms.Form
{
	private System.Windows.Forms.TextBox addressTextBox;
	private System.Windows.Forms.Label label2;
	private System.Windows.Forms.TextBox cityTextBox;
	private System.Windows.Forms.Label label3;
	private System.Windows.Forms.TextBox stateTextBox;
	private System.Windows.Forms.TextBox zipTextBox;
	private System.Windows.Forms.HelpProvider helpProvider1;
	private System.Windows.Forms.Label helpLabel;

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

	public Form1()
	{
        this.addressTextBox = new System.Windows.Forms.TextBox();
        this.helpLabel = new System.Windows.Forms.Label();
        this.label2 = new System.Windows.Forms.Label();
        this.cityTextBox = new System.Windows.Forms.TextBox();
        this.label3 = new System.Windows.Forms.Label();
        this.stateTextBox = new System.Windows.Forms.TextBox();
        this.zipTextBox = new System.Windows.Forms.TextBox();
        
        // Help Label
        this.helpLabel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
        this.helpLabel.Location = new System.Drawing.Point(8, 80);
        this.helpLabel.Size = new System.Drawing.Size(272, 72);
        this.helpLabel.Text = "Click the Help button in the title bar, then click a control " + 
            "to see a Help tooltip for the control.  Click on a control and press F1 to invoke " +
            "the Help system with a sample Help file.";

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

        // Comma Label
        this.label3.Location = new System.Drawing.Point(136, 56);
        this.label3.Size = new System.Drawing.Size(16, 16);
        this.label3.Text = ",";

        // Create the HelpProvider.
        this.helpProvider1 = new System.Windows.Forms.HelpProvider();

        // Tell the HelpProvider what controls to provide help for, and
        // what the help string is.
        this.helpProvider1.SetShowHelp(this.addressTextBox, true);
        this.helpProvider1.SetHelpString(this.addressTextBox, "Enter the street address in this text box.");

        this.helpProvider1.SetShowHelp(this.cityTextBox, true);
        this.helpProvider1.SetHelpString(this.cityTextBox, "Enter the city here.");

        this.helpProvider1.SetShowHelp(this.stateTextBox, true);
        this.helpProvider1.SetHelpString(this.stateTextBox, "Enter the state in this text box.");

        this.helpProvider1.SetShowHelp(this.zipTextBox, true);
        this.helpProvider1.SetHelpString(this.zipTextBox, "Enter the zip code here.");

        // Set what the Help file will be for the HelpProvider.
        this.helpProvider1.HelpNamespace = "mspaint.chm";

        // Sets properties for the different address fields.

        // Address TextBox
        this.addressTextBox.Location = new System.Drawing.Point(16, 24);
        this.addressTextBox.Size = new System.Drawing.Size(264, 20);
        this.addressTextBox.TabIndex = 0;
        this.addressTextBox.Text = "";

        // City TextBox
        this.cityTextBox.Location = new System.Drawing.Point(16, 48);
        this.cityTextBox.Size = new System.Drawing.Size(120, 20);
        this.cityTextBox.TabIndex = 3;
        this.cityTextBox.Text = "";

        // State TextBox
        this.stateTextBox.Location = new System.Drawing.Point(152, 48);
        this.stateTextBox.MaxLength = 2;
        this.stateTextBox.Size = new System.Drawing.Size(32, 20);
        this.stateTextBox.TabIndex = 5;
        this.stateTextBox.Text = "";

        // Zip TextBox
        this.zipTextBox.Location = new System.Drawing.Point(192, 48);
        this.zipTextBox.Size = new System.Drawing.Size(88, 20);
        this.zipTextBox.TabIndex = 6;
        this.zipTextBox.Text = "";

        // Add the controls to the form.
        this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                    this.zipTextBox, this.stateTextBox,
                                    this.label3, this.cityTextBox,
                                    this.label2, this.helpLabel,
                                    this.addressTextBox});

        // Set the form to look like a dialog, and show the HelpButton.    
        this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
        this.HelpButton = true;
        this.MaximizeBox = false;
        this.MinimizeBox = false;
        this.ClientSize = new System.Drawing.Size(292, 160);
        this.Text = "Help Provider Demonstration";

    }
}

import System.*;
import System.Drawing.*;
import System.Windows.Forms.*;

public class Form1 extends System.Windows.Forms.Form
{
    private System.Windows.Forms.TextBox addressTextBox;
    private System.Windows.Forms.Label label2;
    private System.Windows.Forms.TextBox cityTextBox;
    private System.Windows.Forms.Label label3;
    private System.Windows.Forms.TextBox stateTextBox;
    private System.Windows.Forms.TextBox zipTextBox;
    private System.Windows.Forms.HelpProvider helpProvider1;
    private System.Windows.Forms.Label helpLabel;

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

    public Form1()
    {
        this.addressTextBox = new System.Windows.Forms.TextBox();
        this.helpLabel = new System.Windows.Forms.Label();
        this.label2 = new System.Windows.Forms.Label();
        this.cityTextBox = new System.Windows.Forms.TextBox();
        this.label3 = new System.Windows.Forms.Label();
        this.stateTextBox = new System.Windows.Forms.TextBox();
        this.zipTextBox = new System.Windows.Forms.TextBox();
        // Help Label
        this.helpLabel.set_BorderStyle(
            System.Windows.Forms.BorderStyle.Fixed3D);
        this.helpLabel.set_Location(new System.Drawing.Point(8, 80));
        this.helpLabel.set_Size(new System.Drawing.Size(272, 72));
        this.helpLabel.set_Text("Click the Help button in the title bar," 
            + " then click a control to see a Help tooltip for the " 
            + "control.  Click on a control and press F1 to invoke " 
            + "the Help system with a sample Help file.");
        // Address Label
        this.label2.set_Location(new System.Drawing.Point(16, 8));
        this.label2.set_Size(new System.Drawing.Size(100, 16));
        this.label2.set_Text("Address:");
        // Comma Label
        this.label3.set_Location(new System.Drawing.Point(136, 56));
        this.label3.set_Size(new System.Drawing.Size(16, 16));
        this.label3.set_Text(",");

        // Create the HelpProvider.
        this.helpProvider1 = new System.Windows.Forms.HelpProvider();

        // Tell the HelpProvider what controls to provide help for, and
        // what the help string is.
        this.helpProvider1.SetShowHelp(this.addressTextBox, true);
        this.helpProvider1.SetHelpString(this.addressTextBox, 
            "Enter the street address in this text box.");

        this.helpProvider1.SetShowHelp(this.cityTextBox, true);
        this.helpProvider1.SetHelpString(this.cityTextBox, 
            "Enter the city here.");

        this.helpProvider1.SetShowHelp(this.stateTextBox, true);
        this.helpProvider1.SetHelpString(this.stateTextBox, 
            "Enter the state in this text box.");

        this.helpProvider1.SetShowHelp(this.zipTextBox, true);
        this.helpProvider1.SetHelpString(this.zipTextBox, 
            "Enter the zip code here.");
        
        // Set what the Help file will be for the HelpProvider.
        this.helpProvider1.set_HelpNamespace("mspaint.chm");
        // Sets properties for the different address fields.
        // Address TextBox
        this.addressTextBox.set_Location(new System.Drawing.Point(16, 24));
        this.addressTextBox.set_Size(new System.Drawing.Size(264, 20));
        this.addressTextBox.set_TabIndex(0);
        this.addressTextBox.set_Text("");
        // City TextBox
        this.cityTextBox.set_Location(new System.Drawing.Point(16, 48));
        this.cityTextBox.set_Size(new System.Drawing.Size(120, 20));
        this.cityTextBox.set_TabIndex(3);
        this.cityTextBox.set_Text("");
        // State TextBox
        this.stateTextBox.set_Location(new System.Drawing.Point(152, 48));
        this.stateTextBox.set_MaxLength(2);
        this.stateTextBox.set_Size(new System.Drawing.Size(32, 20));
        this.stateTextBox.set_TabIndex(5);
        this.stateTextBox.set_Text("");
        // Zip TextBox
        this.zipTextBox.set_Location(new System.Drawing.Point(192, 48));
        this.zipTextBox.set_Size(new System.Drawing.Size(88, 20));
        this.zipTextBox.set_TabIndex(6);
        this.zipTextBox.set_Text("");
        // Add the controls to the form.
        this.get_Controls().AddRange(new System.Windows.Forms.Control[] { 
            this.zipTextBox, this.stateTextBox, this.label3, this.cityTextBox, 
            this.label2, this.helpLabel, this.addressTextBox });
        // Set the form to look like a dialog, and show the HelpButton.    
        this.set_FormBorderStyle(
            System.Windows.Forms.FormBorderStyle.FixedDialog);
        this.set_HelpButton(true);
        this.set_MaximizeBox(false);
        this.set_MinimizeBox(false);
        this.set_ClientSize(new System.Drawing.Size(292, 160));
        this.set_Text("Help Provider Demonstration");
    } //Form1 
} //Form1

System.Object
   System.MarshalByRefObject
     System.ComponentModel.Component
      System.Windows.Forms.HelpProvider

Los miembros estáticos públicos (Shared en Visual Basic) de este tipo son seguros para la ejecución de subprocesos. No se garantiza que los miembros de instancias sean seguros para la ejecución de subprocesos.

Windows 98, Windows 2000 Service Pack 4, Windows CE, Windows Millennium, Windows Mobile para Pocket PC, Windows Mobile para Smartphone, Windows Server 2003, Windows XP Media Center, Windows XP Professional x64, Windows XP SP2, Windows XP Starter

Microsoft .NET Framework 3.0 es compatible con Windows Vista, Microsoft Windows XP SP2 y Windows Server 2003 SP1.

.NET Framework

Compatible con: 3.0, 2.0, 1.1, 1.0
Mostrar: