Aracılığıyla paylaş


DrawToolTipEventArgs.ToolTipText Özellik

Tanım

Çizilmekte olan metni ToolTip alır.

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

Özellik Değeri

Olay gerçekleştiğinde Draw ile ToolTip ilişkili metin.

Örnekler

Aşağıdaki kod örneğinde özel çizim işleminin nasıl yapılacağını gösterilmektedir ToolTip. Örnek bir ToolTip oluşturur ve üzerinde bulunan üç Button denetimle Formilişkilendirir. Örnek, özelliğini true olarak ayarlar OwnerDraw ve olayı işler Draw . Olay işleyicisinde Draw , ToolTip özelliği tarafından gösterildiği gibi öğesinin ToolTip hangi düğme için görüntülendiğine bağlı olarak özel olarak çizilir DrawToolTipEventArgs.AssociatedControl .

Aşağıdaki kod alıntısı yöntemini ve , ToolTipTextve Graphics özelliklerini kullanmayı BoundsgösterirDrawBorder. Kod örneğinin DrawToolTipEventArgs tamamı için sınıfa genel bakış bölümüne bakın.

// 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

Açıklamalar

Genellikle ToolTip'inizi ToolTipText özel olarak çizerken ToolTip metninin ne olduğunu belirlemek için özelliğini kullanırsınız. Araç İpucu metninin Graphics.DrawString çizimini özelleştirmek için yöntemini kullanabilirsiniz. ToolTip metninin sistem tarafından belirtilen stil kullanılarak çizilmiş olmasını istiyorsanız yöntemini kullanın DrawText . Metin değeri, sınıfının yöntemine SetToolTipToolTip geçirilen değerden gelir.

Şunlara uygulanır

Ayrıca bkz.