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.v25.2.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