Share via


ToolTip.SetToolTip(Control, String) Yöntem

Tanım

Araç İpucu metnini belirtilen denetimle ilişkilendirir.

public:
 void SetToolTip(System::Windows::Forms::Control ^ control, System::String ^ caption);
public void SetToolTip (System.Windows.Forms.Control control, string caption);
public void SetToolTip (System.Windows.Forms.Control control, string? caption);
member this.SetToolTip : System.Windows.Forms.Control * string -> unit
Public Sub SetToolTip (control As Control, caption As String)

Parametreler

control
Control

Control Araç İpucu metnini ilişkilendirmek için.

caption
String

İşaretçi denetim üzerindeyken görüntülenecek Araç İpucu metni.

Örnekler

Aşağıdaki kod örneği sınıfının bir örneğini ToolTip oluşturur ve örneği, örneğin oluşturulduğu örnekle Form ilişkilendirir. Kod daha sonra , InitialDelayve ReshowDelaygecikme özelliklerini AutoPopDelaybaşlatır. Sınıfın örneği ek olarak, formun ToolTip etkin olup olmamasına bakılmaksızın ToolTip metninin görüntülenmesini sağlamak için özelliğini true olarak ayarlarShowAlways. Son olarak, örnek ToolTip metnini formdaki iki denetimle ilişkilendirir: a Button ve CheckBox. Bu örnek, örnekte tanımlanan yöntemin adlı bir Form denetimi ve adlı button1checkBox1bir Button denetimi içeren bir CheckBox içinde yer aldığını ve yönteminin oluşturucusundan Formçağrıldığını gerektirir.

// 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

Açıklamalar

Denetim için görüntülenecek Araç İpucu metnini belirtmeye ek olarak, denetimin Araç İpucu metnini değiştirmek için de bu yöntemi kullanabilirsiniz. SetToolTip Belirli bir denetim için yöntemini birden çok kez çağırmak, denetim için görüntülenecek birden çok Araç İpucu metni belirtmez, bunun yerine denetimin geçerli Araç İpucu metnini değiştirir. Çalışma zamanında bir denetimle ilişkili ToolTip metnini belirlemek için yöntemini kullanın GetToolTip .

Genel bir kural olarak kullanılan metin kısa olmalıdır; ancak, çıkış karakteri dizisini kullanarak satır sonları \r\n ekleyebilirsiniz. Metindeki ve işareti (&) özelliği tarafından StripAmpersands açıklandığı gibi işlenir.

Şunlara uygulanır

Ayrıca bkz.