ToolTip Constructors

Definition

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

Overloads

ToolTip()

初始化没有指定容器的 ToolTip 的新实例。Initializes a new instance of the ToolTip without a specified container.

ToolTip(IContainer)

使用指定的容器初始化 ToolTip 类的新实例。Initializes a new instance of the ToolTip class with a specified container.

ToolTip()

初始化没有指定容器的 ToolTip 的新实例。Initializes a new instance of the ToolTip without a specified container.

public:
 ToolTip();
public ToolTip ();
Public Sub New ()

Examples

下面的代码示例创建 ToolTip 类的实例。The following code example creates an instance of the ToolTip class. 然后,该代码将 AutoPopDelayInitialDelayReshowDelay初始化延迟属性。The code then initializes the delay properties AutoPopDelay, InitialDelay, and ReshowDelay. 此外,ToolTip 类的实例将 ShowAlways 属性设置为 true,以启用显示工具提示文本,而不管窗体是否处于活动状态。In addition the instance of the ToolTip class sets the ShowAlways property to true to enable ToolTip text to be displayed regardless of whether the form is active. 最后,该示例将工具提示文本与窗体上的两个控件、ButtonCheckBox相关联。Finally, the example associates ToolTip text with two controls on a form, a Button and a CheckBox. 此代码示例要求在示例中定义的方法位于包含名为 button1Button 控件和名为 checkBox1,CheckBox 控件的 Form 中,并且该方法是从 Form的构造函数中调用的。The code example requires that the method defined in the example is located within a Form that contains a Button control named button1 and a CheckBox control named checkBox1, and that the method is called from the constructor of the Form.

// This example assumes that the Form_Load event handling method
// is connected to the Load event of the form.
void Form1_Load( Object^ sender, System::EventArgs^ e )
{
   // Create the ToolTip and associate with the Form container.
   ToolTip^ toolTip1 = gcnew ToolTip;
   
   // Set up the delays for the ToolTip.
   toolTip1->AutoPopDelay = 5000;
   toolTip1->InitialDelay = 1000;
   toolTip1->ReshowDelay = 500;
   // Force the ToolTip text to be displayed whether or not the form is active.
   toolTip1->ShowAlways = true;
   
   // Set up the ToolTip text for the Button and Checkbox.
   toolTip1->SetToolTip( this->button1, "My button1" );
   toolTip1->SetToolTip( this->checkBox1, "My checkBox1" );
}
// This example assumes that the Form_Load event handling method
// is connected to the Load event of the form.
private void Form1_Load(object sender, System.EventArgs e)
{
   // Create the ToolTip and associate with the Form container.
   ToolTip toolTip1 = new ToolTip();

   // Set up the delays for the ToolTip.
   toolTip1.AutoPopDelay = 5000;
   toolTip1.InitialDelay = 1000;
   toolTip1.ReshowDelay = 500;
   // Force the ToolTip text to be displayed whether or not the form is active.
   toolTip1.ShowAlways = true;
      
   // Set up the ToolTip text for the Button and Checkbox.
   toolTip1.SetToolTip(this.button1, "My button1");
   toolTip1.SetToolTip(this.checkBox1, "My checkBox1");
}
' This example assumes that the Form_Load event handling method
' is connected to the Load event of the form.
Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles MyBase.Load
   ' Create the ToolTip and associate with the Form container.
   Dim toolTip1 As New ToolTip()
   
   ' Set up the delays for the ToolTip.
   toolTip1.AutoPopDelay = 5000
   toolTip1.InitialDelay = 1000
   toolTip1.ReshowDelay = 500
   ' Force the ToolTip text to be displayed whether or not the form is active.
   toolTip1.ShowAlways = True
   
   ' Set up the ToolTip text for the Button and Checkbox.
   toolTip1.SetToolTip(Me.button1, "My button1")
   toolTip1.SetToolTip(Me.checkBox1, "My checkBox1")
End Sub

Remarks

此构造函数创建不与任何容器关联的工具提示的实例。This constructor creates an instance of a ToolTip not associated with any container.

See also

ToolTip(IContainer)

使用指定的容器初始化 ToolTip 类的新实例。Initializes a new instance of the ToolTip class with a specified container.

public:
 ToolTip(System::ComponentModel::IContainer ^ cont);
public ToolTip (System.ComponentModel.IContainer cont);
new System.Windows.Forms.ToolTip : System.ComponentModel.IContainer -> System.Windows.Forms.ToolTip
Public Sub New (cont As IContainer)

Parameters

cont
IContainer

IContainer 表示 ToolTip 的容器。An IContainer that represents the container of the ToolTip.

Remarks

ToolTip 构造函数使你能够将 ToolTip 与任何 Container 对象相关联。The ToolTip constructor enables you to associate a ToolTip with any Container object. 通过以这种方式关联 ToolTip,你可以将工具提示的生存期的控制移交给 ContainerBy associating the ToolTip in this manner, you hand over control of the lifetime of the ToolTip to the Container. 如果你在应用程序中使用多个组件,并且想要同时处理它们,这会很有用。This can be useful if you use several components in your application, and want to dispose of all of them at the same time. 例如,如果将 ToolTipImageListTimerContainer相关联,则对 Dispose 调用 Container 还将强制处理所有这些组件。For example, if you associate a ToolTip, an ImageList, and a Timer with a Container, calling Dispose on the Container will also force disposal of all of these components.

See also

Applies to