Share via


DrawToolTipEventArgs.DrawText 方法

定義

使用系統的文字色彩和字型,並選擇性地使用特定格式選項,繪製 ToolTip 的文字。

多載

DrawText()

使用系統的文字色彩和字型來繪製 ToolTip 的文字。

DrawText(TextFormatFlags)

使用系統的文字色彩和字型,以及指定的文字配置,繪製 ToolTip 的文字。

DrawText()

使用系統的文字色彩和字型來繪製 ToolTip 的文字。

public:
 void DrawText();
public void DrawText ();
member this.DrawText : unit -> unit
Public Sub DrawText ()

範例

下列程式碼範例示範如何自訂繪製 ToolTip 。 此範例會建立 ,並將它與位於 上的 FormButtonToolTip 控制項產生關聯。 此範例會將 OwnerDraw 屬性設定為 true,並處理 Draw 事件。 在 事件處理常式中 DrawToolTip 會根據 屬性所指示 DrawToolTipEventArgs.AssociatedControl 顯示的按鈕 ToolTip ,以不同的方式繪製 。

下列程式碼摘錄示範如何使用 DrawBorderDrawBackgroundDrawText 方法。 如需完整的程式碼範例, DrawToolTipEventArgs 請參閱 類別概觀。

// Draw the ToolTip using default values if the ToolTip is for button3.
else if ( e->AssociatedControl == button3 )
{
   e->DrawBackground();
   e->DrawBorder();
   e->DrawText();
}
// Draw the ToolTip using default values if the ToolTip is for button3.
else if (e.AssociatedControl == button3)
{
    e.DrawBackground();
    e.DrawBorder();
    e.DrawText();
}
ElseIf (e.AssociatedControl Is button3) Then
    ' Draw the ToolTip using default values if the ToolTip is for button3.
    e.DrawBackground()
    e.DrawBorder()
    e.DrawText()
End If

備註

方法 DrawText() 代表顯示 ToolTip 的預設方法。 這個方法會針對字型色彩使用系統指定的字型和 的 SystemColors.InfoText 目前值。 文字會以水準和垂直方向在 屬性所 Bounds 指定的矩形內繪製成單行置中;它相當於下列對 多載版本的 DrawText(TextFormatFlags) 呼叫:

DrawText(TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter | TextFormatFlags.SingleLine | TextFormatFlags.HidePrefix)

另請參閱

適用於

DrawText(TextFormatFlags)

使用系統的文字色彩和字型,以及指定的文字配置,繪製 ToolTip 的文字。

public:
 void DrawText(System::Windows::Forms::TextFormatFlags flags);
public void DrawText (System.Windows.Forms.TextFormatFlags flags);
member this.DrawText : System.Windows.Forms.TextFormatFlags -> unit
Public Sub DrawText (flags As TextFormatFlags)

參數

flags
TextFormatFlags

TextFormatFlags,其中包含為 ToolTipText 指定顯示和配置之值的位元組合。

備註

方法 DrawText(TextFormatFlags) 可用來自訂 的特定視覺層面 ToolTip ,包括工具提示文字的配置。 這個方法會針對字型色彩使用系統指定的字型和 的 SystemColors.InfoText 目前值。

另請參閱

適用於