ToolTip 建構函式

定義

初始化 ToolTip 類別的新執行個體。

多載

ToolTip()

不使用指定的容器,初始化 ToolTip 的新執行個體。

ToolTip(IContainer)

使用指定的容器,初始化 ToolTip 類別的新執行個體。

ToolTip()

不使用指定的容器,初始化 ToolTip 的新執行個體。

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

範例

下列程式碼範例會建立 類別的 ToolTip 實例。 然後,程式碼會初始化延遲屬性 AutoPopDelayInitialDelayReshowDelay 。 此外,類別的 ToolTip 實例會將 ShowAlways 屬性設定為 true ,以允許顯示工具提示文字,而不論表單是否為使用中。 最後,此範例會將 ToolTip 文字與表單上的兩個 CheckBox 控制項產生關聯, Button 以及 。 程式碼範例會要求範例中定義的 方法位於 內 Form ,其中包含 Button 名為 的控制項和 CheckBox 名為 checkBox1, button1 的控制項,以及從 的 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

備註

此建構函式會建立與任何容器無關的工具提示實例。

另請參閱

適用於

ToolTip(IContainer)

使用指定的容器,初始化 ToolTip 類別的新執行個體。

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 的容器的 ToolTip

備註

ToolTip 構函式可讓您將 與任何 Container 物件產生關聯 ToolTip 。 藉由以這種方式建立關聯 ToolTip ,您會將工具提示 Container 存留期的控制交給 。 如果您在應用程式中使用數個元件,而且想要同時處置所有元件,這非常有用。 例如,如果您將 ToolTip 、、 ImageListTimerContainer 建立關聯,在 上 Container 呼叫 Dispose 也會強制處置所有這些元件。

另請參閱

適用於