Progress® Telerik® Reporting R2 2018

Shape

The Shape report item is used to display one of a selection of predefined shapes on a report. The screenshot below shows a Shape report item with ShapeType="Right Arrow" on the report design surface.

You can use shapes to create visual effects within a report. You can set display and other properties to this item by using the Properties pane.

ShapeType Property modes:

  • Ellipse

  • Vertical Line

  • Horizontal Line

  • Slant Line

  • BackSlant Line

  • Triangle

  • Square

  • Pentagon

  • Hexagon

  • Octagon

  • 3-ray star

  • 4-ray star

  • 5-ray star

  • 6-ray star

  • 8-ray star

  • Top Arrow

  • Bottom Arrow

  • Left Arrow

  • Right Arrow

  • Cross

The Shape report item supports creating a custom shapes programmatically. The following code snippet shows how to inherit the ShapeBase class and provide a custom set of PointF array that will form the shape. The points coordinates are relative and do not depend on the item's size or position in the report.

class CustomShapeType : Drawing.Shapes.ShapeBase
{
    public override object Clone()
    {
        return new CustomShapeType()
        {
            Bounds = this.Bounds
        };
    }

    protected override void CreateShape()
    {
        var points = new System.Drawing.PointF[]
        {
            new System.Drawing.PointF(0.5f, 1.5f),
            new System.Drawing.PointF(2, 0),
            new System.Drawing.PointF(6, 4),
            new System.Drawing.PointF(4, 6),
            new System.Drawing.PointF(2, 4),
            new System.Drawing.PointF(6, 0),
            new System.Drawing.PointF(7.5f, 1.5f)
        };

        base.AddLines(points, false);
    }
}

The Shape item can be created at runtime and added to a report item container (section, panel, etc.). The snippet below shows how to instantiate a Shape item of CustomShape type:

Shape CreateShape()
{
    var shape = new Telerik.Reporting.Shape()
    {
        ShapeType = new CustomShapeType(),
        Size = new Drawing.SizeU(Drawing.Unit.Cm(2), Drawing.Unit.Cm(2)),
        Location = new Drawing.PointU(Drawing.Unit.Cm(1), Drawing.Unit.Cm(1)),
    };
    shape.Style.Color = System.Drawing.Color.Green;
    shape.Style.LineWidth = Drawing.Unit.Pixel(5);

    return shape;
}

See Also

Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article

close
Dummy