Back to Devexpress

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

officefileapi-devexpress-dot-spreadsheet-dot-shapecollection-dot-addshape-x28-devexpress-dot-spreadsheet-dot-shapegeometrypreset-system-dot-single-system-dot-single-system-dot-single-system-dot-single-x29.md

latest4.6 KB
Original Source

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

csharp
Shape AddShape(
    ShapeGeometryPreset shapePreset,
    float x,
    float y,
    float width,
    float height
)
vb
Function AddShape(
    shapePreset As ShapeGeometryPreset,
    x As Single,
    y As Single,
    width As Single,
    height As Single
) As Shape

Parameters

NameTypeDescription
shapePresetShapeGeometryPreset

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

TypeDescription
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.

csharp
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;
vb
Dim shape As 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

ShapeCollection Interface

ShapeCollection Members

DevExpress.Spreadsheet Namespace