Skip to main content
A newer version of this page is available. .

Draw Shapes

  • 14 minutes to read

This document describes how to use the XRShape control for drawing various shapes in a report.

To draw a shape in a report, drag the XRShape control from the DX.18.2: Report Controls Toolbox tab and drop it onto the report.

xrShapes_drop

The XRShape class supports a variety of different shapes. To select a shape, set the XRShape.Shape property to an appropriate descendant of the ShapeBase class. The XRShape.Shape property returns an object that corresponds to a particular shape’s type, and contains all the properties required by this type.

Each shape provides a specific set of properties. For instance, the ShapeArrow class provides the ShapeArrow.ArrowHeight and ShapeArrow.ArrowWidth properties, customizing the appearance of an arrow shown within the XRShape control.

In addition, the XRShape class features the following main properties:

  • The XRShape.Angle property specifies the angle by which the shape’s image is rotated.
  • The XRShape.LineWidth property specifies the width of the line which is used for the shape’s outline.
  • The XRShape.FillColor property specifies the color for filling the shape.
  • The XRShape.Stretch property specifies whether or not to stretch a shape when it is rotated

The following sections in this document describe each of the available shapes in detail:

Arrow

A shape of the Arrow type looks as shown in the image below.

shapesArrow

The following properties should be set to specify a particular arrow of the Arrow type:

  • ShapeArrow.ArrowHeight. This property is used to specify the relative height of the arrow (in percent). The returned value should be from 0 to 100.
  • ShapeArrow.ArrowWidth. This property is used to specify the relative width of the arrow (in percent). The returned value should be from 0 to 100.
  • FilletShapeBase.Fillet. This property is used to specify the relative roundness of the arrow (in percent). The returned value should be from 0 to 100.

This example demonstrates how to create an XRShape Arrow type control, and set its basic properties.

using System;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.XtraReports.UI;
using DevExpress.XtraPrinting.Shape;
//...

private void button1_Click(object sender, EventArgs e) {
    XtraReport1 report = new XtraReport1();

    // Create a shape control.
    XRShape shape = new XRShape();

    // Set the shape's type to Arrow.
    shape.Shape = new ShapeArrow();

    // Adjust the Arrow shape's main properties.
    shape.Angle = 90;
    shape.Width = 200;
    shape.Height = 200;
    shape.ForeColor = Color.Brown;
    shape.FillColor = Color.Beige;
    shape.Stretch = false;

    // Adjust the Arrow shape's specific properties.
    ((ShapeArrow)shape.Shape).ArrowHeight = 50;
    ((ShapeArrow)shape.Shape).ArrowWidth = 50;
    ((ShapeArrow)shape.Shape).Fillet = 20;

    // Preview the report.
    report.Detail.Controls.Add(shape);
    ReportPrintTool pt = new ReportPrintTool(report);
    pt.ShowPreviewDialog();
}

Brace

A shape of the Brace type looks as shown in the image below.

xrShapesBrace

The following property should be set to specify a particular Brace:

  • ShapeBracket.TipLength. This property is used to specify the length of a brace’s tip.
  • ShapeBrace.TailLength. This property is used to specify the length of a brace’s tail.
  • FilletShapeBase.Fillet. This property is used to specify the relative roundness of the brace (in percent). The returned value should be from 0 to 100.

This example demonstrates how to create an XRShape Brace type control, and set its basic properties.

using System;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.XtraReports.UI;
using DevExpress.XtraPrinting.Shape;
//...

private void button1_Click(object sender, EventArgs e) {
    XtraReport1 report = new XtraReport1();

    // Create a shape control.
    XRShape shape = new XRShape();

    // Set the shape's type to Brace.
    shape.Shape = new ShapeBrace();

    // Adjust the Brace shape's main properties.
    shape.Angle = 180;
    shape.Width = 200;
    shape.Height = 200;
    shape.ForeColor = Color.Brown;
    shape.Stretch = false;

    // Adjust the Brace shape's specific properties.
    ((ShapeBrace)shape.Shape).TipLength = 20;
    ((ShapeBrace)shape.Shape).TailLength = 20;
    ((ShapeBrace)shape.Shape).Fillet = 50;

    // Preview the report.
    report.Detail.Controls.Add(shape);
    ReportPrintTool pt = new ReportPrintTool(report);
    pt.ShowPreviewDialog();
}

Bracket

A shape of the Bracket type looks as shown in the image below.

xrShapesBracket

The following property should be set to specify a particular Bracket:

This example demonstrates how to create an XRShape Bracket type control, and set its basic properties.

using System;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.XtraReports.UI;
using DevExpress.XtraPrinting.Shape;
//...

private void button1_Click(object sender, EventArgs e) {
    XtraReport1 report = new XtraReport1();

    // Create a shape control.
    XRShape shape = new XRShape();

    // Set the shape's type to Bracket.
    shape.Shape = new ShapeBracket();

    // Adjust the Bracket shape's main properties.
    shape.Angle = 180;
    shape.Width = 200;
    shape.Height = 200;
    shape.ForeColor = Color.Brown;
    shape.Stretch = false;

    // Adjust the Bracket shape's specific properties.
    ((ShapeBracket)shape.Shape).TipLength = 20;

    // Preview the report.
    report.Detail.Controls.Add(shape);
    ReportPrintTool pt = new ReportPrintTool(report);
    pt.ShowPreviewDialog();
}

Cross

A shape of the Cross type looks as shown in the image below.

xrShapesCross

The following properties should be set to specify a particular Cross:

  • ShapeCross.HorizontalLineWidth. This property is used to specify the horizontal line width of a cross (in percent). The returned value should be from 0 to 100.
  • ShapeCross.VerticalLineWidth. This property is used to specify the vertical line width of a cross (in percent). The returned value should be from 0 to 100.
  • FilletShapeBase.Fillet. This property is used to specify the relative roundness of the cross (in percent). The returned value should be from 0 to 100.

This example demonstrates how to create an XRShape Cross type control, and set its basic properties.

using System;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.XtraReports.UI;
using DevExpress.XtraPrinting.Shape;
//...

private void button1_Click(object sender, EventArgs e) {
    XtraReport1 report = new XtraReport1();

    // Create a shape control.
    XRShape shape = new XRShape();

    // Set the shape's type to Cross.
    shape.Shape = new ShapeCross();

    // Adjust the Cross shape's main properties.
    shape.Angle = 90;
    shape.Width = 200;
    shape.Height = 200;
    shape.ForeColor = Color.Brown;
    shape.FillColor = Color.Beige;
    shape.Stretch = false;

    // Adjust the Cross shape's specific properties.
    ((ShapeCross)shape.Shape).HorizontalLineWidth = 50;
    ((ShapeCross)shape.Shape).VerticalLineWidth = 50;
    ((ShapeCross)shape.Shape).Fillet = 20;

    // Preview the report.
    report.Detail.Controls.Add(shape);
    ReportPrintTool pt = new ReportPrintTool(report);
    pt.ShowPreviewDialog();
}

Ellipse

A shape of the Ellipse type looks as shown in the image below.

xrShapesEllipse

This example demonstrates how to create an XRShape Ellipse type control, and set its basic properties.

using System;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.XtraReports.UI;
using DevExpress.XtraPrinting.Shape;
//...

private void button1_Click(object sender, EventArgs e) {
    XtraReport1 report = new XtraReport1();

    // Create a shape control.
    XRShape shape = new XRShape();

    // Set the shape's type to Ellipse.
    shape.Shape = new ShapeEllipse();

    // Adjust the Ellipse shape's main properties.
    shape.Angle = 90;
    shape.Width = 200;
    shape.Height = 200;
    shape.ForeColor = Color.Brown;
    shape.FillColor = Color.Beige;
    shape.Stretch = false;

    // Preview the report.
    report.Detail.Controls.Add(shape);
    ReportPrintTool pt = new ReportPrintTool(report);
    pt.ShowPreviewDialog();
}

Line

A shape of the Line type looks as shown in the image below.

xrShapesLine

This example demonstrates how to create an XRShape Line type control, and set its basic properties.

using System;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.XtraReports.UI;
using DevExpress.XtraPrinting.Shape;
//...

private void button1_Click(object sender, EventArgs e) {
    XtraReport1 report = new XtraReport1();

    // Create a shape control.
    XRShape shape = new XRShape();

    // Set the shape's type to Line.
    shape.Shape = new ShapeLine();

    // Adjust the Line shape's main properties.
    shape.Angle = 45;
    shape.Width = 200;
    shape.Height = 200;
    shape.ForeColor = Color.Brown;
    shape.Stretch = false;

    // Preview the report.
    report.Detail.Controls.Add(shape);
    ReportPrintTool pt = new ReportPrintTool(report);
    pt.ShowPreviewDialog();
}

Polygon

A shape of the Polygon type looks as shown in the image below.

xrShapesPolygon

The following properties should be set to specify a particular Polygon:

  • ShapePolygon.NumberOfSides. This property is used to specify the number of sides for the polygon.
  • FilletShapeBase.Fillet. This property is used to specify the relative roundness of the polygon (in percent). The returned value should be from 0 to 100.

This example demonstrates how to create an XRShape Polygon type control, and set its basic properties.

using System;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.XtraReports.UI;
using DevExpress.XtraPrinting.Shape;
//...

private void button1_Click(object sender, EventArgs e) {
    XtraReport1 report = new XtraReport1();

    // Create a shape control.
    XRShape shape = new XRShape();

    // Set the shape's type to Polygon.
    shape.Shape = new ShapePolygon();

    // Adjust the Polygon shape's main properties.
    shape.Angle = 90;
    shape.Width = 200;
    shape.Height = 200;
    shape.ForeColor = Color.Brown;
    shape.FillColor = Color.Beige;
    shape.Stretch = false;

    // Adjust the Polygon shape's specific properties.
    ((ShapePolygon)shape.Shape).NumberOfSides = 7;
    ((ShapePolygon)shape.Shape).Fillet = 5;

    // Preview the report.
    report.Detail.Controls.Add(shape);
    ReportPrintTool pt = new ReportPrintTool(report);
    pt.ShowPreviewDialog();
}

Rectangle

A shape of the Rectangle type looks as shown in the image below.

shapesRectangle

The following property should be set to specify a particular of the Rectangle:

  • FilletShapeBase.Fillet. This property is used to specify the relative roundness of the rectangle (in percent). The returned value should be from 0 to 100.

This example demonstrates how to create an XRShape Rectangle type control, and set its basic properties.

using System;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.XtraReports.UI;
using DevExpress.XtraPrinting.Shape;
//...

private void button1_Click(object sender, EventArgs e) {
    XtraReport1 report = new XtraReport1();

    // Create a shape control.
    XRShape shape = new XRShape();

    // Set the shape's type to Rectangle.
    shape.Shape = new ShapeRectangle();

    // Adjust the Rectangle shape's main properties.
    shape.Angle = 90;
    shape.Width = 200;
    shape.Height = 200;
    shape.ForeColor = Color.Brown;
    shape.FillColor = Color.Beige;
    shape.Stretch = false;

    // Adjust the Rectangle shape's specific properties.
    ((ShapeRectangle)shape.Shape).Fillet = 20;

    // Preview the report.
    report.Detail.Controls.Add(shape);
    ReportPrintTool pt = new ReportPrintTool(report);
    pt.ShowPreviewDialog();
}

Star

A shape of the Star type looks as shown in the image below.

xrShapesStar

The following properties should be set to specify a particular Star:

  • ShapeStar.Concavity. This property is used to specify the concavity level (in percent) between two neighboring start points. The returned value should be from 0 to 100.
  • ShapeStar.StarPointCount. This property is used to specify the number of points in the star.
  • FilletShapeBase.Fillet. This property is used to specify the relative roundness of the star points (in percent). The returned value should be from 0 to 100.

This example demonstrates how to create an XRShape Star type control, and set its basic properties.

using System;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.XtraReports.UI;
using DevExpress.XtraPrinting.Shape;
//...

private void button1_Click(object sender, EventArgs e) {
    XtraReport1 report = new XtraReport1();

    // Create a shape control.
    XRShape shape = new XRShape();

    // Set the shape's type to Star.
    shape.Shape = new ShapeStar();

    // Adjust the Star shape's main properties.
    shape.Angle = 90;
    shape.Width = 200;
    shape.Height = 200;
    shape.ForeColor = Color.Brown;
    shape.FillColor = Color.Beige;
    shape.Stretch = false;

    // Adjust the Star shape's specific properties.
    ((ShapeStar)shape.Shape).Concavity = 50;
    ((ShapeStar)shape.Shape).StarPointCount = 7;
    ((ShapeStar)shape.Shape).Fillet = 5;

    // Preview the report.
    report.Detail.Controls.Add(shape);
    ReportPrintTool pt = new ReportPrintTool(report);
    pt.ShowPreviewDialog();
}