ToolTip 建構函式

定義

初始化 ToolTip 類別的新執行個體。Initializes a new instance of the ToolTip class.

多載

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

範例

下列程式碼範例會建立類別的實例 ToolTipThe following code example creates an instance of the ToolTip class. 然後,程式碼會初始化 delay 屬性 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 CheckBoxFinally, the example associates ToolTip text with two controls on a form, a Button and a CheckBox. 程式碼範例需要在包含名為之控制項的中 Form ,以及 Button button1 CheckBox 名為的控制項, checkBox1, 以及從的函式呼叫方法時 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

備註

這個函式會建立未與任何容器相關聯的工具提示實例。This constructor creates an instance of a ToolTip not associated with any container.

另請參閱

適用於

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 的容器的 ToolTipAn IContainer that represents the container of the ToolTip.

備註

此函式可 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. 例如,如果您將 ToolTipImageList 和 a 與建立關聯 Timer ,則 Container 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.

另請參閱

適用於