ToolTip ToolTip ToolTip ToolTip Constructors

定义

重载

ToolTip() ToolTip() ToolTip()

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

ToolTip(IContainer) ToolTip(IContainer) ToolTip(IContainer) ToolTip(IContainer)

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

ToolTip() ToolTip() ToolTip()

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

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

示例

下面的代码示例创建ToolTip类的一个实例。The following code example creates an instance of the ToolTip class. 然后, 该代码初始化延迟属性AutoPopDelayInitialDelayReshowDelayThe 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. 最后, 该示例将工具提示文本与窗体上的Button两个控件 ( CheckBox和) 相关联。Finally, the example associates ToolTip text with two controls on a form, a Button and a CheckBox. 此代码示例要求在示例中定义的Form方法位于Button包含名为button1的控件和CheckBoxcheckBox1,为的控件以及从构造函数中调用方法的FormThe 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

注解

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

另请参阅

ToolTip(IContainer) ToolTip(IContainer) ToolTip(IContainer) 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)

参数

cont
IContainer IContainer IContainer IContainer

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

注解

构造函数使你能够ToolTip将与任何Container对象关联。 ToolTipThe ToolTip constructor enables you to associate a ToolTip with any Container object. 通过ToolTip以这种方式关联, 你可以将工具提示的生存期的控制移交Container给。By 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. 例如, ToolTip如果将ImageList、和Timer与相关联Container, 则对的Container调用Dispose还将强制处理所有这些组件。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.

另请参阅

适用于