menu

WinForms

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

    Show / Hide Table of Contents

    Class ControlDrawing

    Inheritance
    System.Object
    ControlDrawing
    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.Windows.Forms
    Assembly: Syncfusion.Shared.Base.dll
    Syntax
    public class ControlDrawing

    Constructors

    ControlDrawing()

    Declaration
    public ControlDrawing()

    Fields

    DrawTextFlags

    Inflate offset for drawing selection rectangle.

    Declaration
    public const int DrawTextFlags = 2404
    Field Value
    Type
    System.Int32

    Properties

    Offset

    Declaration
    public Point Offset { get; set; }
    Property Value
    Type
    System.Drawing.Point

    Methods

    DrawAlignedText(Graphics, String, Font, Color, Rectangle, ContentAlignment)

    Declaration
    public void DrawAlignedText(Graphics g, string text, Font font, Color color, Rectangle rc, ContentAlignment align)
    Parameters
    Type Name Description
    System.Drawing.Graphics g
    System.String text
    System.Drawing.Font font
    System.Drawing.Color color
    System.Drawing.Rectangle rc
    System.Drawing.ContentAlignment align

    DrawBorder(Graphics, Rectangle, BorderStyle, Border3DStyle, ButtonBorderStyle, Color)

    Declaration
    public void DrawBorder(Graphics g, Rectangle rc, BorderStyle borderStyle, Border3DStyle border3DStyle, ButtonBorderStyle borderSingle, Color borderColor)
    Parameters
    Type Name Description
    System.Drawing.Graphics g
    System.Drawing.Rectangle rc
    System.Windows.Forms.BorderStyle borderStyle
    System.Windows.Forms.Border3DStyle border3DStyle
    System.Windows.Forms.ButtonBorderStyle borderSingle
    System.Drawing.Color borderColor

    DrawBorder(Graphics, Rectangle, BorderStyle, Border3DStyle, ButtonBorderStyle, Color, Border3DSide)

    Declaration
    public void DrawBorder(Graphics g, Rectangle rc, BorderStyle borderStyle, Border3DStyle border3DStyle, ButtonBorderStyle borderSingle, Color borderColor, Border3DSide sides)
    Parameters
    Type Name Description
    System.Drawing.Graphics g
    System.Drawing.Rectangle rc
    System.Windows.Forms.BorderStyle borderStyle
    System.Windows.Forms.Border3DStyle border3DStyle
    System.Windows.Forms.ButtonBorderStyle borderSingle
    System.Drawing.Color borderColor
    System.Windows.Forms.Border3DSide sides

    DrawFillColor(Graphics, Rectangle, Color)

    Declaration
    public void DrawFillColor(Graphics g, Rectangle rc, Color fillColor)
    Parameters
    Type Name Description
    System.Drawing.Graphics g
    System.Drawing.Rectangle rc
    System.Drawing.Color fillColor

    DrawGradient(Graphics, Rectangle, Color, Color)

    Declaration
    public void DrawGradient(Graphics g, Rectangle rc, Color color1, Color color2)
    Parameters
    Type Name Description
    System.Drawing.Graphics g
    System.Drawing.Rectangle rc
    System.Drawing.Color color1
    System.Drawing.Color color2

    DrawImage(Graphics, Rectangle, Image, Boolean)

    Declaration
    public void DrawImage(Graphics g, Rectangle rc, Image img, bool stretchImage)
    Parameters
    Type Name Description
    System.Drawing.Graphics g
    System.Drawing.Rectangle rc
    System.Drawing.Image img
    System.Boolean stretchImage

    DrawMultipleGradient(Graphics, Rectangle, ArrayList, Boolean)

    Declaration
    public void DrawMultipleGradient(Graphics g, Rectangle rc, ArrayList foreColors, bool vertical)
    Parameters
    Type Name Description
    System.Drawing.Graphics g
    System.Drawing.Rectangle rc
    System.Collections.ArrayList foreColors
    System.Boolean vertical

    DrawTube(Graphics, Rectangle, Color, Color)

    Declaration
    public void DrawTube(Graphics g, Rectangle rc, Color color1, Color color2)
    Parameters
    Type Name Description
    System.Drawing.Graphics g
    System.Drawing.Rectangle rc
    System.Drawing.Color color1
    System.Drawing.Color color2

    DrawVerticalGradient(Graphics, Rectangle, Color, Color)

    Declaration
    public void DrawVerticalGradient(Graphics g, Rectangle rc, Color color1, Color color2)
    Parameters
    Type Name Description
    System.Drawing.Graphics g
    System.Drawing.Rectangle rc
    System.Drawing.Color color1
    System.Drawing.Color color2

    GetGradientBrush(Rectangle, Color, Color)

    Declaration
    public Brush GetGradientBrush(Rectangle rc, Color color1, Color color2)
    Parameters
    Type Name Description
    System.Drawing.Rectangle rc
    System.Drawing.Color color1
    System.Drawing.Color color2
    Returns
    Type
    System.Drawing.Brush

    GetTubeBrush(Color, Color, Rectangle)

    Declaration
    public Brush GetTubeBrush(Color color1, Color color2, Rectangle rc)
    Parameters
    Type Name Description
    System.Drawing.Color color1
    System.Drawing.Color color2
    System.Drawing.Rectangle rc
    Returns
    Type
    System.Drawing.Brush

    GetVerticalGradientBrush(Rectangle, Color, Color)

    Declaration
    public Brush GetVerticalGradientBrush(Rectangle rc, Color color1, Color color2)
    Parameters
    Type Name Description
    System.Drawing.Rectangle rc
    System.Drawing.Color color1
    System.Drawing.Color color2
    Returns
    Type
    System.Drawing.Brush

    MeasureDisplayStringSize(Graphics, String, Font, Boolean)

    Returns the width required to draw the text specified using the font specified.

    Declaration
    public static Size MeasureDisplayStringSize(Graphics graphics, string text, Font font, bool mirrored)
    Parameters
    Type Name Description
    System.Drawing.Graphics graphics

    A System.Drawing.Graphics object.

    System.String text

    The text that is to be drawn.

    System.Drawing.Font font

    The System.Drawing.Font using which to draw.

    System.Boolean mirrored

    True - we use RTL, otherwise normal drawing.

    Returns
    Type Description
    System.Drawing.Size

    Width required.

    MeasureDisplayStringSize(Graphics, String, Font, Boolean, Int32)

    Measure string with limit by width.

    Declaration
    public static Size MeasureDisplayStringSize(Graphics graphics, string text, Font font, bool mirrored, int width)
    Parameters
    Type Name Description
    System.Drawing.Graphics graphics
    System.String text
    System.Drawing.Font font
    System.Boolean mirrored
    System.Int32 width

    -1 - apply single line mode for measuring, values greater zero enables multiline measuring mode.

    Returns
    Type
    System.Drawing.Size

    Transform(Graphics, Point)

    Methods recalculate point using Graphics matrix settings. This method required when we will draw on Graphics created from HDC that does not have applied transformations. Very useful when used ControlPaint class for drawing.

    Declaration
    public static Point Transform(Graphics g, Point point)
    Parameters
    Type Name Description
    System.Drawing.Graphics g

    reference on Graphics

    System.Drawing.Point point

    Point to recalculate.

    Returns
    Type Description
    System.Drawing.Point

    Transformed point.

    Transform(Graphics, Rectangle)

    Methods recalculate top left and right bottom points using Graphics matrix settings. This method required when we will draw on Graphics created from HDC that does not have applied transformations. Very useful when used ControlPaint class for drawing.

    Declaration
    public static Rectangle Transform(Graphics g, Rectangle rect)
    Parameters
    Type Name Description
    System.Drawing.Graphics g

    reference on Graphics

    System.Drawing.Rectangle rect

    rectangle to recalculate.

    Returns
    Type Description
    System.Drawing.Rectangle

    Transformed rectangle.

    Remarks

    Methods will work fine only in limited cases. If on graphics applied rotations then in most cases will be wrong calculated rectangle.

    Examples

    Rectangle rcBorders = ControlDrawing.Transform( g, this.Bounds ); ControlDrawing.DrawBorderInternal( g, rcBorders, this.BorderStyle, this.Border3DStyle, this.BorderSingle, this.BorderColor, this.BorderSides );

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