DrawToolTipEventArgs.DrawText Method

Definition

Draws the text of the ToolTip using the system text color and font, and optionally using specific formatting options.

Overloads

DrawText()

Draws the text of the ToolTip using the system text color and font.

DrawText(TextFormatFlags)

Draws the text of the ToolTip using the system text color and font, and the specified text layout.

DrawText()

Draws the text of the ToolTip using the system text color and font.

public void DrawText ();

Examples

The following code example demonstrates how to custom draw the ToolTip. The example creates a ToolTip and associates it to three Button controls located on the Form. The example sets the OwnerDraw property to true and handles the Draw event. In the Draw event handler, the ToolTip is custom drawn differently depending on what button the ToolTip is being displayed for as indicated by the DrawToolTipEventArgs.AssociatedControl property.

The code excerpt below demonstrates using the DrawBorder, DrawBackground, and DrawText methods. See the DrawToolTipEventArgs class overview for the complete code example.

// Draw the ToolTip using default values if the ToolTip is for button3.
else if (e.AssociatedControl == button3)
{
    e.DrawBackground();
    e.DrawBorder();
    e.DrawText();
}

Remarks

The DrawText() method represents the default method of displaying a ToolTip. This method uses the system specified font and the current value of SystemColors.InfoText for the font color. The text is drawn as a single line centered horizontally and vertically within the rectangle specified by the Bounds property; it is equivalent to the following call to the overloaded version of DrawText(TextFormatFlags):

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

See also

Applies to

.NET Framework 4.8.1 וגירסאות אחרות
מוצר גירסאות
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

DrawText(TextFormatFlags)

Draws the text of the ToolTip using the system text color and font, and the specified text layout.

public void DrawText (System.Windows.Forms.TextFormatFlags flags);

Parameters

flags
TextFormatFlags

A TextFormatFlags containing a bitwise combination of values that specifies the display and layout for the ToolTipText.

Remarks

The DrawText(TextFormatFlags) method is used to customize certain visual aspects of a ToolTip, including the layout of the ToolTip text. This method uses the system specified font and the current value of SystemColors.InfoText for the font color.

See also

Applies to

.NET Framework 4.8.1 וגירסאות אחרות
מוצר גירסאות
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9