HelpProvider HelpProvider HelpProvider HelpProvider Class

定义

为控件提供弹出帮助或联机帮助。Provides pop-up or online Help for controls.

public ref class HelpProvider : System::ComponentModel::Component, System::ComponentModel::IExtenderProvider
public class HelpProvider : System.ComponentModel.Component, System.ComponentModel.IExtenderProvider
type HelpProvider = class
    inherit Component
    interface IExtenderProvider
Public Class HelpProvider
Inherits Component
Implements IExtenderProvider
继承
实现

示例

下面的代码示例演示了如何使用HelpProvider类包含四个地址字段的窗体上显示上下文相关帮助。The following code example demonstrates using the HelpProvider class to display context-sensitive Help on a form containing four address fields. 该示例使用SetHelpString方法设置的帮助工具提示文本。The example uses the SetHelpString method to set the Help ToolTip text. 当您使用上下文相关帮助按钮,然后单击上的地址字段中,帮助光标帮助工具提示显示具有指定文本。When you use the context-sensitive Help button and click the Help cursor on an address field, the Help ToolTip appears with the specified text. 当您按 F1 键与地址字段中的焦点时,显示 mspaint.chm 帮助文件,因为HelpNamespace属性已设置为 mspaint.chm。When you press the F1 key with the focus in an address field, the mspaint.chm Help file is displayed because the HelpNamespace property has been set to mspaint.chm. SetShowHelp方法调用的每个地址控件用来标识它具有可用的帮助内容。The SetShowHelp method is called for each address control to identify that it has Help content available.

#using <System.dll>
#using <System.Windows.Forms.dll>
#using <System.Drawing.dll>

using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;
public ref class Form1: public System::Windows::Forms::Form
{
private:
   System::Windows::Forms::TextBox^ addressTextBox;
   System::Windows::Forms::Label ^ label2;
   System::Windows::Forms::TextBox^ cityTextBox;
   System::Windows::Forms::Label ^ label3;
   System::Windows::Forms::TextBox^ stateTextBox;
   System::Windows::Forms::TextBox^ zipTextBox;
   System::Windows::Forms::HelpProvider^ helpProvider1;
   System::Windows::Forms::Label ^ helpLabel;

public:
   Form1()
   {
      this->addressTextBox = gcnew System::Windows::Forms::TextBox;
      this->helpLabel = gcnew System::Windows::Forms::Label;
      this->label2 = gcnew System::Windows::Forms::Label;
      this->cityTextBox = gcnew System::Windows::Forms::TextBox;
      this->label3 = gcnew System::Windows::Forms::Label;
      this->stateTextBox = gcnew System::Windows::Forms::TextBox;
      this->zipTextBox = gcnew System::Windows::Forms::TextBox;
      
      // Help Label
      this->helpLabel->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
      this->helpLabel->Location = System::Drawing::Point( 8, 80 );
      this->helpLabel->Size = 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 = System::Drawing::Point( 16, 8 );
      this->label2->Size = System::Drawing::Size( 100, 16 );
      this->label2->Text = "Address:";
      
      // Comma Label
      this->label3->Location = System::Drawing::Point( 136, 56 );
      this->label3->Size = System::Drawing::Size( 16, 16 );
      this->label3->Text = ", ";
      
      // Create the HelpProvider.
      this->helpProvider1 = gcnew 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 = System::Drawing::Point( 16, 24 );
      this->addressTextBox->Size = System::Drawing::Size( 264, 20 );
      this->addressTextBox->TabIndex = 0;
      this->addressTextBox->Text = "";
      
      // City TextBox
      this->cityTextBox->Location = System::Drawing::Point( 16, 48 );
      this->cityTextBox->Size = System::Drawing::Size( 120, 20 );
      this->cityTextBox->TabIndex = 3;
      this->cityTextBox->Text = "";
      
      // State TextBox
      this->stateTextBox->Location = System::Drawing::Point( 152, 48 );
      this->stateTextBox->MaxLength = 2;
      this->stateTextBox->Size = System::Drawing::Size( 32, 20 );
      this->stateTextBox->TabIndex = 5;
      this->stateTextBox->Text = "";
      
      // Zip TextBox
      this->zipTextBox->Location = System::Drawing::Point( 192, 48 );
      this->zipTextBox->Size = System::Drawing::Size( 88, 20 );
      this->zipTextBox->TabIndex = 6;
      this->zipTextBox->Text = "";
      
      // Add the controls to the form.
      array<System::Windows::Forms::Control^>^temp0 = {this->zipTextBox,this->stateTextBox,this->label3,this->cityTextBox,this->label2,this->helpLabel,this->addressTextBox};
      this->Controls->AddRange( temp0 );
      
      // 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 = System::Drawing::Size( 292, 160 );
      this->Text = "Help Provider Demonstration";
   }

};


[STAThread]
int main()
{
   Application::Run( gcnew Form1 );
}

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";

    }
}
Imports System
Imports System.Drawing
Imports System.Windows.Forms

Public Class Form1
    Inherits System.Windows.Forms.Form
    Private addressTextBox As System.Windows.Forms.TextBox
    Private label2 As System.Windows.Forms.Label
    Private cityTextBox As System.Windows.Forms.TextBox
    Private label3 As System.Windows.Forms.Label
    Private stateTextBox As System.Windows.Forms.TextBox
    Private zipTextBox As System.Windows.Forms.TextBox
    Private helpProvider1 As System.Windows.Forms.HelpProvider
    Private helpLabel As System.Windows.Forms.Label

    <STAThread()>  _
    Shared Sub Main()
        Application.Run(New Form1())
    End Sub 'Main
    
    Public Sub New()
        Me.addressTextBox = New System.Windows.Forms.TextBox()
        Me.helpLabel = New System.Windows.Forms.Label()
        Me.label2 = New System.Windows.Forms.Label()
        Me.cityTextBox = New System.Windows.Forms.TextBox()
        Me.label3 = New System.Windows.Forms.Label()
        Me.stateTextBox = New System.Windows.Forms.TextBox()
        Me.zipTextBox = New System.Windows.Forms.TextBox()

        ' Help Label
        Me.helpLabel.Location = New System.Drawing.Point(8, 80)
        Me.helpLabel.Size = New System.Drawing.Size(272, 72)
        Me.helpLabel.TabIndex = 1
        Me.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
        Me.label2.Location = New System.Drawing.Point(16, 8)
        Me.label2.Size = New System.Drawing.Size(100, 16)
        Me.label2.Text = "Address:"

        ' Comma Label
        Me.label3.Location = New System.Drawing.Point(136, 56)
        Me.label3.Size = New System.Drawing.Size(16, 16)
        Me.label3.Text = ","

        ' Creates the HelpProvider.
        Me.helpProvider1 = New System.Windows.Forms.HelpProvider()

        ' Tell the HelpProvider what controls to provide Help for, and
        ' what the Help string is.
        Me.helpProvider1.SetHelpString(Me.addressTextBox, "Enter the street address in this text box.")
        Me.helpProvider1.SetShowHelp(Me.addressTextBox, True)

        Me.helpProvider1.SetHelpString(Me.cityTextBox, "Enter the city here.")
        Me.helpProvider1.SetShowHelp(Me.cityTextBox, True)

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

        Me.helpProvider1.SetHelpString(Me.zipTextBox, "Enter the zip code here.")
        Me.helpProvider1.SetShowHelp(Me.zipTextBox, True)

        ' Sets what the Help file will be for the HelpProvider.
        Me.helpProvider1.HelpNamespace = "mspaint.chm"

        ' Set properties for the different address fields.

        ' Address TextBox
        Me.addressTextBox.Location = New System.Drawing.Point(16, 24)
        Me.addressTextBox.Size = New System.Drawing.Size(264, 20)
        Me.addressTextBox.TabIndex = 0
        Me.addressTextBox.Text = ""


        ' City TextBox
        Me.cityTextBox.Location = New System.Drawing.Point(16, 48)
        Me.cityTextBox.Size = New System.Drawing.Size(120, 20)
        Me.cityTextBox.TabIndex = 3
        Me.cityTextBox.Text = ""

        ' State TextBox
        Me.stateTextBox.Location = New System.Drawing.Point(152, 48)
        Me.stateTextBox.MaxLength = 2
        Me.stateTextBox.Size = New System.Drawing.Size(32, 20)
        Me.stateTextBox.TabIndex = 5
        Me.stateTextBox.Text = ""

        ' Zip TextBox
        Me.zipTextBox.Location = New System.Drawing.Point(192, 48)
        Me.zipTextBox.Size = New System.Drawing.Size(88, 20)
        Me.zipTextBox.TabIndex = 6
        Me.zipTextBox.Text = ""

        ' Add the controls to the form.
        Me.Controls.AddRange(New System.Windows.Forms.Control() { Me.zipTextBox, _
                                       Me.stateTextBox, Me.label3, _
                                       Me.cityTextBox, Me.label2, _
                                       Me.helpLabel, Me.addressTextBox})

        ' Set the form to look like a dialog, and show the HelpButton.    
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
        Me.HelpButton = True
        Me.MaximizeBox = False
        Me.MinimizeBox = False
        Me.ClientSize = New System.Drawing.Size(292, 160)
        Me.Text = "Help Provider Demonstration"

    End Sub 'New        
End Class 'Form1

注解

每个实例HelpProvider保持一个对与之关联的控件的引用的集合。Each instance of HelpProvider maintains a collection of references to controls associated with it. 若要将帮助文件与相关联HelpProvider,请将HelpNamespace属性。To associate a Help file with the HelpProvider, set the HelpNamespace property. 指定通过调用提供的帮助类型SetHelpNavigator方法并提供HelpNavigator指定控件的值。You specify the type of Help provided by calling the SetHelpNavigator method and providing a HelpNavigator value for the specified control. 你提供的关键字或主题的帮助通过调用SetHelpKeyword方法。You provide the keyword or topic for the Help by calling the SetHelpKeyword method. 若要打开到特定主题的帮助,关键字应传递在窗体topicName.htm。To open Help to a specific topic, the keyword should be passed in the form topicName.htm.

若要将特定的帮助字符串与控件相关联,请使用SetHelpString方法。To associate a specific Help string with a control, use the SetHelpString method. 在用户按 F1 键在控件有焦点时,您将使用此方法的控件相关联的字符串显示弹出窗口中。The string that you associate with a control using this method is displayed in a pop-up window when the user presses the F1 key while the control has focus.

如果HelpNamespace未设置属性,则必须使用SetHelpString方法以提供帮助文本。If the HelpNamespace property has not been set, you must use the SetHelpString method to provide the Help text. 如果同时设置了HelpNamespace和帮助字符串,帮助根据HelpNamespace将优先。If you have set both HelpNamespace and the Help string, Help based on the HelpNamespace will take precedence.

HelpProvider 在调用方法Help类以提供帮助功能。HelpProvider calls methods on the Help class to provide Help functionality.

构造函数

HelpProvider() HelpProvider() HelpProvider() HelpProvider()

初始化 HelpProvider 类的新实例。Initializes a new instance of the HelpProvider class.

属性

CanRaiseEvents CanRaiseEvents CanRaiseEvents CanRaiseEvents

获取一个指示组件是否可以引发事件的值。Gets a value indicating whether the component can raise an event.

(Inherited from Component)
Container Container Container Container

获取 IContainer,它包含 ComponentGets the IContainer that contains the Component.

(Inherited from Component)
DesignMode DesignMode DesignMode DesignMode

获取一个值,用以指示 Component 当前是否处于设计模式。Gets a value that indicates whether the Component is currently in design mode.

(Inherited from Component)
Events Events Events Events

获取附加到此 Component 的事件处理程序的列表。Gets the list of event handlers that are attached to this Component.

(Inherited from Component)
HelpNamespace HelpNamespace HelpNamespace HelpNamespace

获取或设置一个值,指定与此相关的帮助文件的名称HelpProvider对象。Gets or sets a value specifying the name of the Help file associated with this HelpProvider object.

Site Site Site Site

获取或设置 ComponentISiteGets or sets the ISite of the Component.

(Inherited from Component)
Tag Tag Tag Tag

获取或设置包含有关的补充数据的对象HelpProviderGets or sets the object that contains supplemental data about the HelpProvider.

方法

CanExtend(Object) CanExtend(Object) CanExtend(Object) CanExtend(Object)

指定此对象是否可以提供其扩展程序属性设置为指定的对象。Specifies whether this object can provide its extender properties to the specified object.

CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

创建一个对象,该对象包含生成用于与远程对象进行通信的代理所需的全部相关信息。Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
Dispose() Dispose() Dispose() Dispose()

释放由 Component 使用的所有资源。Releases all resources used by the Component.

(Inherited from Component)
Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

释放由 Component 占用的非托管资源,还可以另外再释放托管资源。Releases the unmanaged resources used by the Component and optionally releases the managed resources.

(Inherited from Component)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetHelpKeyword(Control) GetHelpKeyword(Control) GetHelpKeyword(Control) GetHelpKeyword(Control)

返回指定控件的帮助关键字。Returns the Help keyword for the specified control.

GetHelpNavigator(Control) GetHelpNavigator(Control) GetHelpNavigator(Control) GetHelpNavigator(Control)

返回当前HelpNavigator设置为指定的控件。Returns the current HelpNavigator setting for the specified control.

GetHelpString(Control) GetHelpString(Control) GetHelpString(Control) GetHelpString(Control)

返回指定控件的弹出帮助窗口的内容。Returns the contents of the pop-up Help window for the specified control.

GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

检索控制此实例的生存期策略的当前生存期服务对象。Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetService(Type) GetService(Type) GetService(Type) GetService(Type)

返回一个对象,该对象表示由 Component 或它的 Container 提供的服务。Returns an object that represents a service provided by the Component or by its Container.

(Inherited from Component)
GetShowHelp(Control) GetShowHelp(Control) GetShowHelp(Control) GetShowHelp(Control)

返回一个值,该值指示是否应显示指定的控件的帮助。Returns a value indicating whether the specified control's Help should be displayed.

GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

获取生存期服务对象来控制此实例的生存期策略。Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

创建当前 MarshalByRefObject 对象的浅表副本。Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
ResetShowHelp(Control) ResetShowHelp(Control) ResetShowHelp(Control) ResetShowHelp(Control)

移除与指定控件关联的帮助。Removes the Help associated with the specified control.

SetHelpKeyword(Control, String) SetHelpKeyword(Control, String) SetHelpKeyword(Control, String) SetHelpKeyword(Control, String)

指定用于检索帮助,当用户调用指定控件的帮助的关键字。Specifies the keyword used to retrieve Help when the user invokes Help for the specified control.

SetHelpNavigator(Control, HelpNavigator) SetHelpNavigator(Control, HelpNavigator) SetHelpNavigator(Control, HelpNavigator) SetHelpNavigator(Control, HelpNavigator)

指定从指定的控件的帮助文件中检索帮助时要使用的帮助命令。Specifies the Help command to use when retrieving Help from the Help file for the specified control.

SetHelpString(Control, String) SetHelpString(Control, String) SetHelpString(Control, String) SetHelpString(Control, String)

指定与指定控件关联的帮助字符串。Specifies the Help string associated with the specified control.

SetShowHelp(Control, Boolean) SetShowHelp(Control, Boolean) SetShowHelp(Control, Boolean) SetShowHelp(Control, Boolean)

指定是否为指定的控件显示帮助。Specifies whether Help is displayed for the specified control.

ToString() ToString() ToString() ToString()

返回表示当前 HelpProvider 的字符串。Returns a string that represents the current HelpProvider.

事件

Disposed Disposed Disposed Disposed

当通过调用 Dispose() 方法释放组件时发生。Occurs when the component is disposed by a call to the Dispose() method.

(Inherited from Component)

适用于

另请参阅