ToolTip.SetToolTip(Control, String) Metódus
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Elemleírás szövegének társítása a megadott vezérlővel.
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)
Paraméterek
- caption
- String
Az elemleírás szövege, amely akkor jelenik meg, ha az egérmutató a vezérlőn van.
Példák
Az alábbi példakód létrehozza az ToolTip osztály egy példányát, és társítja a példányt azzal, Form amelyikben a példány létrejön. A kód ezután inicializálja a késleltetési tulajdonságokat AutoPopDelay, InitialDelayés ReshowDelay. Emellett az osztály példánya úgy állítja be a ToolTipShowAlways tulajdonságot, hogy true engedélyezze az elemleírás szövegének megjelenítését, függetlenül attól, hogy az űrlap aktív-e. Végül a példa az Elemleírás szöveget két vezérlőelemmel társítja egy űrlapon, az a Button és a CheckBox. Ez a példa megköveteli, hogy a példában definiált metódus egy FormButton elnevezett button1 vezérlőelemet és egy CheckBox elnevezett checkBox1vezérlőelemet tartalmaz, és hogy a metódus a konstruktortól Formlegyen meghívva.
// 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
Megjegyzések
A vezérlőelemhez megjelenítendő elemleírás-szöveg megadása mellett ezzel a módszerrel módosíthatja a vezérlőelem elemleírásának szövegét is. Ha egy vezérlőelemhez többször is meghívja a SetToolTip metódust, az nem ad meg több elemleírást a vezérlőelemhez, hanem módosítja a vezérlő aktuális elemleírás-szövegét. A vezérlőkhöz futtatáskor társított elemleírás szövegének meghatározásához használja a metódust GetToolTip .
Általános szabályként a használt szövegnek rövidnek kell lennie; A feloldó karaktersorozat használatával \r\n azonban sortöréseket is beszúrhat. A szöveg ampersands (> karaktereit) a tulajdonság által leírt módon kezeli a StripAmpersands rendszer.