다음을 통해 공유


ToolTip 클래스

마우스 포인터를 컨트롤 위에 놓을 때 해당 컨트롤에 대한 간단한 설명을 표시하는 작은 사각형 모양의 팝업 창을 나타냅니다.

네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)

구문

‘선언
Public Class ToolTip
    Inherits Component
    Implements IExtenderProvider
‘사용 방법
Dim instance As ToolTip
public class ToolTip : Component, IExtenderProvider
public ref class ToolTip : public Component, IExtenderProvider
public class ToolTip extends Component implements IExtenderProvider
public class ToolTip extends Component implements IExtenderProvider

설명

ToolTip 클래스를 사용하면 포인터가 컨트롤 위에 있을 때 사용자에게 힌트를 제공할 수 있습니다. ToolTip 클래스는 일반적으로 해당 컨트롤의 용도를 알리는 데 사용됩니다. 예를 들어, 컨트롤에 입력할 이름의 형식을 지정하여 이름을 허용하는 TextBox 컨트롤에 대한 도구 설명 텍스트를 지정할 수 있습니다. ToolTip 클래스를 사용하면 힌트뿐만 아니라 런타임 상태 정보도 표시할 수 있습니다. 예를 들어, 인터넷 연결 상태를 표시하는 PictureBox 컨트롤 위로 마우스 포인터를 이동할 때 ToolTip 클래스를 사용하여 연결 속도 및 회선 품질 데이터를 표시할 수 있습니다.

ToolTip 클래스는 모든 컨테이너에 사용될 수 있습니다. 컨테이너를 명시적으로 지정하려면 ToolTip(IContainer) 생성자를 사용합니다. 일반적으로 ToolTip 구성 요소 하나를 사용하여 단일 폼의 여러 컨트롤에 대한 도구 설명을 만듭니다. ToolTip을 만든 후에는 SetToolTip 메서드를 별도로 호출하여 도구 설명 표시 텍스트를 개별 컨트롤에 연결합니다. 이렇게 하면 사용자가 포인터를 컨트롤 위로 이동할 때 해당되는 도구 설명 텍스트가 표시됩니다. 같은 컨트롤에 대해 SetToolTip을 두 번 이상 호출하여 해당 컨트롤과 연결된 텍스트를 변경할 수 있습니다. 컨트롤과 연결된 텍스트를 가져오려면 GetToolTip 메서드를 사용합니다. ToolTip 클래스 인스턴스와 연결된 모든 도구 설명 텍스트를 제거하려면 RemoveAll 메서드를 사용합니다.

참고

비활성화된 컨트롤에 대해서는 도구 설명 텍스트가 표시되지 않습니다. ShowAlways 속성을 true로 설정하지 않으면 컨테이너가 비활성 상태일 때 도구 설명이 표시되지 않습니다.

ToolTip 클래스는 도구 설명의 기본 동작과 모양을 수정하는 다음과 같은 속성과 메서드를 제공합니다.

범주

연관된 멤버

수동 표시

Active, Show, Hide, ShowAlways, Popup, StopTimer

도구 설명 타이밍

AutoPopDelay, InitialDelay, ReshowDelay, AutomaticDelay, StopTimer

내용

SetToolTip, GetToolTip, StripAmpersands, ToolTipIcon, ToolTipTitle, RemoveAll

모양

BackColor, ForeColor, IsBalloon, OwnerDraw, UseAnimation, UseFading

응용 프로그램에 표시되지 않도록 도구 설명 텍스트를 모두 비활성화하려면 Active 속성을 사용합니다. 일반적으로 도구 설명은 운영 체제에서 그리지만 OwnerDraw 속성을 true로 설정하고 Draw 이벤트를 처리하여 ToolTip의 모양을 사용자 지정할 수 있습니다.

ToolTipTitle 클래스는 단일 메서드 CanExtend가 있는 System.ComponentModel.IExtenderProvider 인터페이스를 구현합니다. 도구 설명은 같은 폼에 있는 컨트롤을 디자인 타임에 확장하여 ToolTip 속성을 추가합니다. Extender 공급자에 대한 자세한 내용은 Extender 공급자를 참조하십시오.

예제

다음 코드 예제에서는 ToolTip 클래스의 인스턴스를 만든 다음 이 인스턴스가 만들어진 Form과 연결합니다. 그런 다음 지연 속성(AutoPopDelay, InitialDelayReshowDelay)을 초기화합니다 또한 ToolTip 클래스의 인스턴스는 ShowAlways 속성을 true로 설정하여 해당 폼의 활성화 여부에 관계없이 도구 설명 텍스트가 항상 표시되도록 합니다. 마지막으로 이 예제에서는 도구 설명 텍스트를 폼에 있는 두 개의 컨트롤(ButtonCheckBox)과 연결합니다. 이 코드 예제를 실행하려면 예제에 정의된 메서드가 button1(Button 컨트롤)과 checkBox1(CheckBox 컨트롤)이 포함된 Form 안에 있고 Form의 생성자에서 호출되어야 합니다.

' 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 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.
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.set_AutoPopDelay(5000);
    toolTip1.set_InitialDelay(1000);
    toolTip1.set_ReshowDelay(500);
    // Force the ToolTip text to be displayed whether or not the form
    // is active.
    toolTip1.set_ShowAlways(true);
    // Set up the ToolTip text for the Button and Checkbox.
    toolTip1.SetToolTip(this.button1, "My button1");
    toolTip1.SetToolTip(this.checkBox1, "My checkBox1");
} //Form1_Load

상속 계층 구조

System.Object
   System.MarshalByRefObject
     System.ComponentModel.Component
      System.Windows.Forms.ToolTip

스레드로부터의 안전성

이 형식의 모든 public static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

참고 항목

참조

ToolTip 멤버
System.Windows.Forms 네임스페이스
ToolTipIcon
HelpProvider 클래스

기타 리소스

Extender 공급자
ToolTip 구성 요소(Windows Forms)