다음을 통해 공유


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 ToolTip 텍스트를 연결할 개체입니다.

caption
String

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

예제

다음 코드 예제에서는 클래스의 인스턴스를 ToolTip 만들고 인스턴스가 만들어진 인스턴스와 Form 연결합니다. 그런 다음, 이 코드는 지연 속성 AutoPopDelayInitialDelayReshowDelay. 또한 클래스의 인스턴스는 폼이 ToolTip 활성 상태인지 여부에 관계없이 도구 설명 텍스트를 표시할 수 있도록 속성을 true 설정합니다ShowAlways. 마지막으로, 이 예제에서는 도구 설명 텍스트를 폼의 컨트롤 2개와 a 및 a Button 와 연결합니다 CheckBox. 이 예제에서는 예제에 정의된 메서드가 명명된 컨트롤과 CheckBox 명명 button1checkBox1된 컨트롤을 포함하는 Button 메서드 내에 Form 있고 메서드가 생성자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 된 대로 처리됩니다.

적용 대상

추가 정보