共用方式為


ToolTip 建構函式

定義

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

多載

名稱 Description
ToolTip()

初始化一個沒有指定容器的新 ToolTip 實例。

ToolTip(IContainer)

初始化一個新的類別實例 ToolTip ,並指定容器。

ToolTip()

來源:
ToolTip.cs
來源:
ToolTip.cs
來源:
ToolTip.cs
來源:
ToolTip.cs
來源:
ToolTip.cs

初始化一個沒有指定容器的新 ToolTip 實例。

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

範例

以下程式碼範例建立該 ToolTip 類別的實例。 接著程式碼初始化延遲屬性 AutoPopDelayInitialDelayReshowDelay和 。 此外,該類別實例 ToolTip 會將屬性設 ShowAlways 為 , true 使工具提示文字無論表單是否啟用都能顯示。 最後,範例將 ToolTip 文字與表單上的兩個控制項 a ButtonCheckBoxa 關聯起來。 程式碼範例要求該範例中定義的方法位於 Form 包含 Button 一個名為 button1CheckBox 一個控制點命名 checkBox1, 的 中,且該方法必須從 的建構子 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.cs
來源:
ToolTip.cs
來源:
ToolTip.cs
來源:
ToolTip.cs
來源:
ToolTip.cs

初始化一個新的類別實例 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 構子讓你能將 a ToolTip 與任何 Container 物件關聯。 透過這種方式關聯 , ToolTip 你將工具提示的生命週期控制權交給了 Container。 如果你在應用程式中使用多個元件,並想一次性處理所有元件,這會很有用。 例如,如果你將 a ToolTip、an ImageList、 和 a TimerContainer關聯,呼叫 Dispose 意志時, Container 也會強制處置所有這些成分。

另請參閱

適用於