DrawToolTipEventArgs.DrawText Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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();
public void DrawText ();
member this.DrawText : unit -> unit
Public Sub 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();
}
// 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
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
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);
public void DrawText (System.Windows.Forms.TextFormatFlags flags);
member this.DrawText : System.Windows.Forms.TextFormatFlags -> unit
Public Sub DrawText (flags As TextFormatFlags)
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.