DrawToolTipEventArgs.ToolTipText 속성

정의

그리고 있는 ToolTip의 텍스트를 가져옵니다.

public:
 property System::String ^ ToolTipText { System::String ^ get(); };
public string ToolTipText { get; }
public string? ToolTipText { get; }
member this.ToolTipText : string
Public ReadOnly Property ToolTipText As String

속성 값

ToolTip 이벤트가 발생할 때 Draw과 연결된 텍스트입니다.

예제

다음 코드 예제에서는 사용자 지정 그리기 방법은 ToolTip합니다. 이 예에서는 만듭니다는 ToolTip 3 연결 Button 컨트롤에 있는 Form. 예제에서는 합니다 OwnerDraw 속성을 true로 처리 합니다 Draw 이벤트입니다. 에 Draw 이벤트 처리기는 ToolTip 는 사용자 지정 단추에 따라 다르게 그려집니다를 ToolTip 나타난 것 처럼 표시 되는 DrawToolTipEventArgs.AssociatedControl 속성.

다음 코드 부분은 사용을 보여 줍니다.는 DrawBorder 메서드와 사용 하 여는 BoundsToolTipText, 및 Graphics 속성입니다. 참조 된 DrawToolTipEventArgs 전체 코드 예제에 대 한 클래스 개요입니다.

// Draw a custom background and text if the ToolTip is for button2.
else

// Draw a custom background and text if the ToolTip is for button2.
if ( e->AssociatedControl == button2 )
{
   // Draw the custom background.
   e->Graphics->FillRectangle( SystemBrushes::ActiveCaption, e->Bounds );
   
   // Draw the standard border.
   e->DrawBorder();
   
   // Draw the custom text.
   // The using block will dispose the StringFormat automatically.
   StringFormat^ sf = gcnew StringFormat;
   try
   {
      sf->Alignment = StringAlignment::Center;
      sf->LineAlignment = StringAlignment::Center;
      sf->HotkeyPrefix = System::Drawing::Text::HotkeyPrefix::None;
      sf->FormatFlags = StringFormatFlags::NoWrap;
      System::Drawing::Font^ f = gcnew System::Drawing::Font( "Tahoma",9 );
      try
      {
         e->Graphics->DrawString( e->ToolTipText, f, SystemBrushes::ActiveCaptionText, e->Bounds, sf );
      }
      finally
      {
         if ( f )
            delete safe_cast<IDisposable^>(f);
      }

   }
   finally
   {
      if ( sf )
         delete safe_cast<IDisposable^>(sf);
   }
}
// Draw a custom background and text if the ToolTip is for button2.
else if (e.AssociatedControl == button2)
{
    // Draw the custom background.
    e.Graphics.FillRectangle(SystemBrushes.ActiveCaption, e.Bounds);

    // Draw the standard border.
    e.DrawBorder();

    // Draw the custom text.
    // The using block will dispose the StringFormat automatically.
    using (StringFormat sf = new StringFormat())
    {
        sf.Alignment = StringAlignment.Center;
        sf.LineAlignment = StringAlignment.Center;
        sf.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.None;
        sf.FormatFlags = StringFormatFlags.NoWrap;
        using (Font f = new Font("Tahoma", 9))
        {
            e.Graphics.DrawString(e.ToolTipText, f, 
                SystemBrushes.ActiveCaptionText, e.Bounds, sf);
        }
    }
}
ElseIf (e.AssociatedControl Is button2) Then
    ' Draw a custom background and text if the ToolTip is for button2.

    ' Draw the custom background.
    e.Graphics.FillRectangle(SystemBrushes.ActiveCaption, e.Bounds)

    ' Draw the standard border.
    e.DrawBorder()

    ' Draw the custom text.
    Dim sf As StringFormat = New StringFormat
    Try
        sf.Alignment = StringAlignment.Center
        sf.LineAlignment = StringAlignment.Center
        sf.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.None
        sf.FormatFlags = StringFormatFlags.NoWrap

        Dim f As Font = New Font("Tahoma", 9)
        Try
            e.Graphics.DrawString(e.ToolTipText, f, _
                SystemBrushes.ActiveCaptionText, _
                RectangleF.op_Implicit(e.Bounds), sf)
        Finally
            f.Dispose()
        End Try
    Finally
        sf.Dispose()
    End Try

설명

일반적으로 사용 하 여는 ToolTipText 결정 도구 설명 텍스트를 그리기 도구 설명 사용자 지정 속성입니다. 사용할 수는 Graphics.DrawString 도구 설명 텍스트를 그리는 사용자 지정 하는 방법입니다. 지정 된 시스템을 사용 하 여 도구 설명 텍스트 스타일을 사용 하려는 경우는 DrawText 메서드. 에 전달 된 값에서 텍스트 값을 가져옵니다 합니다 SetToolTip 메서드는 ToolTip 클래스입니다.

적용 대상

추가 정보