ToolTip.SetToolTip(Control, String) 메서드

정의

도구 설명 텍스트를 지정된 컨트롤과 연결시킵니다.

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)

매개 변수

control
Control

도구 설명 텍스트와 연결할 Control입니다.

caption
String

포인터가 컨트롤 위에 있을 때 표시할 도구 설명 텍스트입니다.

예제

다음 코드 예제에서는 클래스의 ToolTip instance 만들고 instance Form instance 만든 에 연결합니다. 그런 다음, 코드는 지연 속성 AutoPopDelay, InitialDelayReshowDelay을 초기화합니다. 또한 클래스의 ToolTip instance 설정 합니다 속성 true 은 폼이 활성 여부에 관계 없이 표시 될 도구 설명 텍스트를 사용 하도록 설정 ShowAlways 합니다. 마지막으로 도구 설명 텍스트를 폼 Button 의 컨트롤 2개와 및 를 연결합니다 CheckBox. 이 예제에서는 예제에 정의된 메서드가 라는 button1 컨트롤과 CheckBox 라는 컨트롤checkBox1을 포함하는 ButtonForm 있고 메서드가 의 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

설명

컨트롤에 대해 표시할 도구 설명 텍스트를 지정하는 것 외에도 이 메서드를 사용하여 컨트롤의 도구 설명 텍스트를 수정할 수도 있습니다. 지정된 컨트롤에 SetToolTip 대해 메서드를 두 번 이상 호출해도 컨트롤에 표시할 도구 설명 텍스트가 여러 개 지정되지 않고 컨트롤의 현재 도구 설명 텍스트가 변경됩니다. 런타임에 컨트롤과 연결된 도구 설명 텍스트를 확인하려면 메서드를 GetToolTip 사용합니다.

일반적으로 사용된 텍스트는 짧아야 합니다. 그러나 이스케이프 문자 시퀀스를 사용하여 줄 바꿈을 삽입할 \r\n 수 있습니다. 텍스트의 앰퍼샌드(&)는 속성에 설명 StripAmpersands 된 대로 처리됩니다.

적용 대상

추가 정보