DrawToolTipEventArgs.Graphics Özellik

Tanım

çiziminde ToolTipkullanılan grafik yüzeyini alır.

public:
 property System::Drawing::Graphics ^ Graphics { System::Drawing::Graphics ^ get(); };
public System.Drawing.Graphics Graphics { get; }
member this.Graphics : System.Drawing.Graphics
Public ReadOnly Property Graphics As Graphics

Özellik Değeri

üzerinde Graphics öğesinin çizildiği yer ToolTip.

Ö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 bunu üzerinde bulunan üç Button denetimle ilişkilendirir Form. Örnek, özelliğini true olarak ayarlar OwnerDraw ve olayı işler Draw . Olay işleyicisindeDraw, ToolTip özelliği tarafından DrawToolTipEventArgs.AssociatedControl gösterildiği gibi hangi düğme ToolTip için görüntülendiğine bağlı olarak özel olarak çizilir.

Aşağıdaki kod alıntısı ve DrawBackground yöntemlerini ve DrawText özelliğini kullanmayı Graphics gösterir. Kod örneğinin DrawToolTipEventArgs tamamı için sınıfa genel bakış bölümüne bakın.

// Draw a custom 3D border if the ToolTip is for button1.
if ( e->AssociatedControl == button1 )
{
   // Draw the standard background.
   e->DrawBackground();
   
   // Draw the custom border to appear 3-dimensional.
   array<Point>^ temp1 = {Point(0,e->Bounds.Height - 1),Point(0,0),Point(e->Bounds.Width - 1,0)};
   e->Graphics->DrawLines( SystemPens::ControlLightLight, temp1 );
   array<Point>^ temp2 = {Point(0,e->Bounds.Height - 1),Point(e->Bounds.Width - 1,e->Bounds.Height - 1),Point(e->Bounds.Width - 1,0)};
   e->Graphics->DrawLines( SystemPens::ControlDarkDark, temp2 );
   
   // Specify custom text formatting flags.
   TextFormatFlags sf = static_cast<TextFormatFlags>(TextFormatFlags::VerticalCenter | TextFormatFlags::HorizontalCenter | TextFormatFlags::NoFullWidthCharacterBreak);
   
   // Draw the standard text with customized formatting options.
   e->DrawText( sf );
}
// Draw a custom 3D border if the ToolTip is for button1.
if (e.AssociatedControl == button1)
{
    // Draw the standard background.
    e.DrawBackground();

    // Draw the custom border to appear 3-dimensional.
    e.Graphics.DrawLines(SystemPens.ControlLightLight, new Point[] {
        new Point (0, e.Bounds.Height - 1), 
        new Point (0, 0), 
        new Point (e.Bounds.Width - 1, 0)
    });
    e.Graphics.DrawLines(SystemPens.ControlDarkDark, new Point[] {
        new Point (0, e.Bounds.Height - 1), 
        new Point (e.Bounds.Width - 1, e.Bounds.Height - 1), 
        new Point (e.Bounds.Width - 1, 0)
    });

    // Specify custom text formatting flags.
    TextFormatFlags sf = TextFormatFlags.VerticalCenter |
                         TextFormatFlags.HorizontalCenter |
                         TextFormatFlags.NoFullWidthCharacterBreak;

    // Draw the standard text with customized formatting options.
    e.DrawText(sf);
}
' Draw a custom 3D border if the ToolTip is for button1.
If (e.AssociatedControl Is button1) Then
    ' Draw the standard background.
    e.DrawBackground()

    ' Draw the custom border to appear 3-dimensional.
    e.Graphics.DrawLines( _
        SystemPens.ControlLightLight, New Point() { _
        New Point(0, e.Bounds.Height - 1), _
        New Point(0, 0), _
        New Point(e.Bounds.Width - 1, 0)})
    e.Graphics.DrawLines( _
        SystemPens.ControlDarkDark, New Point() { _
        New Point(0, e.Bounds.Height - 1), _
        New Point(e.Bounds.Width - 1, e.Bounds.Height - 1), _
        New Point(e.Bounds.Width - 1, 0)})

    ' Specify custom text formatting flags.
    Dim sf As TextFormatFlags = TextFormatFlags.VerticalCenter Or _
                         TextFormatFlags.HorizontalCenter Or _
                         TextFormatFlags.NoFullWidthCharacterBreak

    ' Draw standard text with customized formatting options.
    e.DrawText(sf)

Açıklamalar

nesnesini kullanarak Graphics bir ToolTipöğesinin belirli görsel yönlerinin çizimini özelleştirebilirsiniz. Örneğin, yöntemini kullanarak Graphics.FillRectangle kendi ToolTip arka planınızı çizebilirsiniz.

özelliği tarafından Bounds belirtilen dikdörtgenin dışında yapılan özel çizimler gösterilmez. Olayı işleyerek gösterilmeden önce öğesinin ToolTipToolTip.Popup sınırlarını artırabilirsiniz.

sınıfı, DrawToolTipEventArgs işletim sistemi tarafından kullanılan standart şekilde tek tek bölümlerini ToolTip çizmek için ve DrawTextDrawBorder yöntemlerini de sağlarDrawBackground. Bu yöntemleri nesne yöntemleriyle Graphics birlikte kullanarak ToolTip'inizin bazı bölümlerini standart yapabilir ve diğer bölümleri özelleştirebilirsiniz.

Şunlara uygulanır