Skip to main content
Row

ShapeCollection.AddShape(ShapeGeometryPreset, Single, Single, Single, Single) Method

Inserts a shape with a specific geometry type.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v24.1.Core.dll

NuGet Package: DevExpress.Spreadsheet.Core

Declaration

Shape AddShape(
    ShapeGeometryPreset shapePreset,
    float x,
    float y,
    float width,
    float height
)

Parameters

Name Type Description
shapePreset ShapeGeometryPreset

One of the ShapeGeometryPreset enumeration values indicating the shape’s geometry type.

x Single

A Single value indicating the distance from the left of the worksheet.

y Single

A Single value indicating the distance from the top of the worksheet.

width Single

A Single value that is shape’s width.

height Single

A Single value that is the shape’s height.

Returns

Type Description
Shape

A Shape object that is the resulting shape.

Remarks

Note

The ISpreadsheetComponent.Unit property determines the units of linear dimensions (x, y, width, height).

Use the Shape.ShapeType property to determine a drawing object’s type in ShapeCollection. The ShapeGeometry.Preset property returns the shape’s geometry type.

Change the shape’s fill and outline settings using the Shape.Fill and Shape.Outline properties.

The Shape.Rotation property allows you to define the shape’s rotation angle.

Delete the shape using the ShapeCollection.RemoveAt or Shape.Delete method.

Example

The code sample below shows how to create a shape and adjust its appearance.

Spreadsheet_AddShape

Shape shape = worksheet.Shapes.AddShape(ShapeGeometryPreset.DownArrow, 100, 0, 500, 500);

// Define the shape's fill and outline color.
shape.Fill.SetGradientFill(ShapeGradientType.Circle, Color.Chocolate, Color.Beige);
shape.Outline.SetSolidFill(Color.SaddleBrown);

// Specify the shape's rotation angle.
shape.Rotation = -60;
See Also