menu

WinForms

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class TextPainter - WindowsForms API Reference | Syncfusion

    Show / Hide Table of Contents

    Class TextPainter

    Represents a class that provides the options to paint the text and rotated text.

    Inheritance
    System.Object
    TextPainter
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: Syncfusion.WinForms.Core
    Assembly: Syncfusion.Shared.Base.dll
    Syntax
    public static class TextPainter

    Methods

    DrawRichText(Graphics, String, RectangleF)

    Draws the rich text on the given graphics based on the text, font, fore color and wrap text mode.

    Declaration
    public static void DrawRichText(Graphics graphics, string rtfText, RectangleF rectangle)
    Parameters
    Type Name Description
    System.Drawing.Graphics graphics

    The graphics context.

    System.String rtfText

    The string value contains the rich text content.

    System.Drawing.RectangleF rectangle

    The rectangle value used to draw the rich text.

    DrawRichText(Graphics, String, RectangleF, Font, Color, Boolean, RightToLeft)

    Draws the rich text on the given graphics based on the text, font, fore color and wrap text mode.

    Declaration
    public static void DrawRichText(Graphics graphics, string rtfText, RectangleF rectangle, Font font, Color foreColor, bool wrapText, RightToLeft rightToLeft)
    Parameters
    Type Name Description
    System.Drawing.Graphics graphics

    The graphics context.

    System.String rtfText

    The string value contains the rich text content.

    System.Drawing.RectangleF rectangle

    The rectangle value used to draw the rich text.

    System.Drawing.Font font

    The font value used to draw the rich text.

    System.Drawing.Color foreColor

    The fore color value used to draw the rich text.

    System.Boolean wrapText

    A boolean value indicates rich text allows wrap text or not.

    System.Windows.Forms.RightToLeft rightToLeft

    A value indicates the right to left mode.

    DrawRotatedString(Graphics, String, Font, Brush, Rectangle, StringFormat, Single)

    Draws the text based on the rotation angle information.

    Declaration
    public static void DrawRotatedString(Graphics g, string text, Font font, Brush br, Rectangle rect, StringFormat format, float angle)
    Parameters
    Type Name Description
    System.Drawing.Graphics g

    The graphics.

    System.String text

    The String value used to measure the size.

    System.Drawing.Font font

    The Font value used to calculate the string bounds.

    System.Drawing.Brush br

    The Brush information used to draw the string.

    System.Drawing.Rectangle rect

    The Rectangle value used to draw the rotated string.

    System.Drawing.StringFormat format

    A System.Drawing.StringFormat context.

    System.Single angle

    The rotation angle.

    DrawRotatedString(Graphics, String, Font, Brush, RectangleF, StringFormat, Single)

    Draws the text based on the rotation angle information.

    Declaration
    public static void DrawRotatedString(Graphics g, string text, Font font, Brush br, RectangleF rect, StringFormat format, float angle)
    Parameters
    Type Name Description
    System.Drawing.Graphics g

    The graphics.

    System.String text

    The string value used to measure the size.

    System.Drawing.Font font

    The font value used to calculate the string bounds.

    System.Drawing.Brush br

    The brush information used to draw the string.

    System.Drawing.RectangleF rect

    The rectangle value used to draw the rotated string.

    System.Drawing.StringFormat format

    A System.Drawing.StringFormat context.

    System.Single angle

    The rotation angle.

    DrawString(IntPtr, String, Font, Rectangle, Boolean)

    Draws the text in the specified rectangle based on the System.Drawing.Font value.

    Declaration
    public static void DrawString(IntPtr hdc, string text, Font font, Rectangle rectangle, bool isRightToLeft)
    Parameters
    Type Name Description
    System.IntPtr hdc

    A handle to the device context.

    System.String text

    String to measure.

    System.Drawing.Font font

    System.Drawing.Fontthat defines the text format of the string.

    System.Drawing.Rectangle rectangle

    System.Drawing.Rectanglethat specifies the maximum layout area for the text.

    System.Boolean isRightToLeft

    True - we use RTL, otherwise normal drawing.

    DrawString(IntPtr, String, Font, Rectangle, Color, Boolean)

    Draws the text in the specified rectangle based on the System.Drawing.Color and System.Drawing.Font values.

    Declaration
    public static void DrawString(IntPtr hdc, string text, Font font, Rectangle rectangle, Color textColor, bool isRightToLeft)
    Parameters
    Type Name Description
    System.IntPtr hdc

    A handle to the device context.

    System.String text

    String to measure.

    System.Drawing.Font font

    System.Drawing.Fontthat defines the text format of the string.

    System.Drawing.Rectangle rectangle

    System.Drawing.Rectanglethat specifies the maximum layout area for the text.

    System.Drawing.Color textColor

    The text color.

    System.Boolean isRightToLeft

    True - we use RTL, otherwise normal drawing.

    GetRichTextSize(String, Size, Font, Boolean, RightToLeft)

    Calculates the size of the rich text box based on the font and text values.

    Declaration
    public static Size GetRichTextSize(string rtfText, Size preferredSize, Font font, bool wrapText, RightToLeft rightToLeft)
    Parameters
    Type Name Description
    System.String rtfText

    The string value contains rich text.

    System.Drawing.Size preferredSize

    The preferred size used to draw the rich text.

    System.Drawing.Font font

    The System.Drawing.Font value.

    System.Boolean wrapText

    A boolean value indicates rich text allows wrap text or not.

    System.Windows.Forms.RightToLeft rightToLeft

    A value indicates the right to left mode.

    Returns
    Type Description
    System.Drawing.Size

    Returns the size of the rich text box.

    MeasureRotatedString(Graphics, String, Font, Int32, StringFormat, Single)

    Measures the string bounds based on the angle information.

    Declaration
    public static SizeF MeasureRotatedString(Graphics g, string text, Font font, int width, StringFormat format, float angle)
    Parameters
    Type Name Description
    System.Drawing.Graphics g

    The graphics.

    System.String text

    The string value used to measure the size.

    System.Drawing.Font font

    The font value used to calculate the string bounds.

    System.Int32 width

    The width value.

    System.Drawing.StringFormat format

    A System.Drawing.StringFormat context.

    System.Single angle

    The rotation angle.

    Returns
    Type Description
    System.Drawing.SizeF

    Returns the measured string size based on the angle.

    MeasureRotatedString(SizeF, Single)

    Measures the string bounds based on the angle information.

    Declaration
    public static SizeF MeasureRotatedString(SizeF stringSize, float angle)
    Parameters
    Type Name Description
    System.Drawing.SizeF stringSize

    The actual string size value.

    System.Single angle

    The angle value.

    Returns
    Type Description
    System.Drawing.SizeF

    Returns the measured rotated string size value.

    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved