ReoGrid
DOCUMENT
Drawing Shapes

Overview

ReoGrid supports adding drawing shapes — rectangles, ellipses, lines, diamonds, rounded rectangles, pie shapes, and more — directly onto a worksheet. Shapes are managed through the worksheet.FloatingObjects collection and belong to the unvell.ReoGrid.Drawing.Shapes namespace.

using unvell.ReoGrid.Drawing;
using unvell.ReoGrid.Drawing.Shapes;

Adding a Shape to a Worksheet

Create a shape instance, configure its position and size, then add it to FloatingObjects.

var worksheet = grid.CurrentWorksheet;

var rect = new RectangleShape()
{
    Location = new Graphics.Point(60, 90),
    Size = new Graphics.Size(160, 80),
    Text = "Hello ReoGrid",
};

worksheet.FloatingObjects.Add(rect);

All shapes share the same Location / Size / Bounds positioning API inherited from DrawingObject.

Available Shape Types

Rectangle

var rect = new RectangleShape()
{
    Location = new Graphics.Point(60, 90),
    Size = new Graphics.Size(160, 80),
};
worksheet.FloatingObjects.Add(rect);

Ellipse

var ellipse = new EllipseShape()
{
    Location = new Graphics.Point(60, 90),
    Size = new Graphics.Size(120, 80),
};
worksheet.FloatingObjects.Add(ellipse);

Diamond

var diamond = new DiamondShape()
{
    Location = new Graphics.Point(60, 90),
    Size = new Graphics.Size(120, 80),
};
worksheet.FloatingObjects.Add(diamond);

Rounded Rectangle

Use RoundRate (0.0 – 1.0) to control the corner radius relative to the shorter side.

var rounded = new RoundedRectangleShape()
{
    Location = new Graphics.Point(60, 90),
    Size = new Graphics.Size(160, 80),
    RoundRate = 0.3f,
};
worksheet.FloatingObjects.Add(rounded);

Pie

var pie = new PieShape()
{
    Location = new Graphics.Point(60, 90),
    Size = new Graphics.Size(120, 120),
    StartAngle = 0f,
    SweepAngle = 270f,
};
worksheet.FloatingObjects.Add(pie);

Block Arc

var arc = new BlockArcShape()
{
    Location = new Graphics.Point(60, 90),
    Size = new Graphics.Size(120, 120),
    StartAngle = -90f,
    SweepAngle = 180f,
    ArcWidth = 20f,
};
worksheet.FloatingObjects.Add(arc);

Line

A Line is positioned by StartPoint and EndPoint. You can add arrow caps to either end.

var line = new Line()
{
    StartPoint = new Graphics.Point(60, 130),
    EndPoint = new Graphics.Point(220, 130),
};

line.Style.LineWidth = 1.5f;
line.Style.EndCap = Graphics.LineCapStyles.Arrow;

worksheet.FloatingObjects.Add(line);

Setting Text

All shapes derived from ShapeObject (Rectangle, Ellipse, Diamond, etc.) support a Text property.

rect.Text = "My Label";

Styling

Access the Style property on any shape to customize its appearance.

Fill Color

rect.Style.FillColor = Graphics.SolidColor.LightYellow;

Line Color and Width

rect.Style.LineColor = Graphics.SolidColor.Navy;
rect.Style.LineWidth = 2.0f;

Line Style

rect.Style.LineStyle = Graphics.LineStyles.Dash;

Available LineStyles values:

ValueDescription
SolidSolid line (default)
DashDashed line
DotDotted line
DashDotDash-dot line
DashDotDotDash-dot-dot line

Text Color and Alignment

rect.Style.TextColor = Graphics.SolidColor.DarkBlue;
rect.Style.HorizontalAlignment = Drawing.HorizontalAlignment.Center;
rect.Style.VerticalAlignment = Drawing.VerticalAlignment.Middle;

Line Cap Styles (for Line shapes)

line.Style.StartCap = Graphics.LineCapStyles.Ellipse;
line.Style.EndCap   = Graphics.LineCapStyles.Arrow;

Available LineCapStyles values:

ValueDescription
NoneNo cap (default)
ArrowArrow head
EllipseEllipse cap
RoundRound cap

Rotation

Rotate any shape around its center point using RotateAngle (degrees).

rect.RotateAngle = 45f;

Complete Style Example

var rect = new RectangleShape()
{
    Location = new Graphics.Point(120, 90),
    Size = new Graphics.Size(160, 100),
    Text = "Styled Shape",
};

rect.Style.FillColor  = Graphics.SolidColor.LightGoldenrodYellow;
rect.Style.LineColor  = Graphics.SolidColor.LimeGreen;
rect.Style.LineWidth  = 3f;
rect.RotateAngle = 15f;

worksheet.FloatingObjects.Add(rect);

Managing Shapes

// Remove a specific shape
worksheet.FloatingObjects.Remove(rect);

// Remove all shapes
worksheet.FloatingObjects.Clear();

// Iterate all shapes
foreach (var obj in worksheet.FloatingObjects)
{
    Console.WriteLine(obj.Bounds);
}

// Count shapes
int count = worksheet.FloatingObjects.Count;

API Reference

Common Properties (all shapes)

PropertyTypeDescription
LocationGraphics.PointTop-left position on the worksheet
SizeGraphics.SizeWidth and height
BoundsGraphics.RectanglePosition and size combined
X, YRGFloatIndividual coordinates
Width, HeightRGFloatIndividual dimensions
RotateAngleRGFloatRotation angle in degrees (0 = no rotation)
VisibleboolWhether the shape is visible
StyleIDrawingObjectStyleStyle object for fill, line, and text

ShapeObject Properties (Rectangle, Ellipse, Diamond, etc.)

PropertyTypeDescription
TextstringText displayed inside the shape
Style.TextColorSolidColorColor of the text
Style.HorizontalAlignmentHorizontalAlignmentHorizontal text alignment
Style.VerticalAlignmentVerticalAlignmentVertical text alignment

RoundedRectangleShape

PropertyTypeDescription
RoundRateRGFloatCorner roundness (0.0 = sharp, 1.0 = fully round)

PieShape

PropertyTypeDescription
StartAngleRGFloatStart angle in degrees
SweepAngleRGFloatSweep angle in degrees

BlockArcShape

PropertyTypeDescription
StartAngleRGFloatStart angle in degrees
SweepAngleRGFloatSweep angle in degrees
ArcWidthRGFloatThickness of the arc

Line

PropertyTypeDescription
StartPointGraphics.PointStart position of the line
EndPointGraphics.PointEnd position of the line
Style.StartCapLineCapStylesCap style at start point
Style.EndCapLineCapStylesCap style at end point
Style.LineWidthRGFloatWidth of the line
Style.LineColorSolidColorColor of the line

IDrawingObjectStyle Properties (via shape.Style)

PropertyTypeDescription
FillColorIColorBackground fill color
LineColorSolidColorOutline color
LineWidthRGFloatOutline width
LineStyleLineStylesOutline style (Solid, Dash, Dot, etc.)

Was the content of the page helpful?

© 2012-2026UNVELL Inc.