Skip to main content
Row

ShapeCollection.GroupShapes(IList<Shape>) Method

Groups shapes into a shape group.

Namespace: DevExpress.Spreadsheet

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

NuGet Package: DevExpress.Spreadsheet.Core

Declaration

Shape GroupShapes(
    IList<Shape> shapes
)

Parameters

Name Type Description
shapes IList<Shape>

A collection of shapes to be grouped.

Returns

Type Description
Shape

A shape group.

Remarks

Use the Shape.ShapeType property to determine a drawing object’s type in ShapeCollection.

The shape group can contain nested shape groups.

Call the ShapeCollection.UngroupShapes method to split the shape group into individual shapes. The ShapeCollection.UngroupShapes method call does not split child shape groups into individual shapes.

Example

The code sample below shows how to combine three shapes into a shape group using the ShapeCollection.GroupShapes method:

XtraSpreadsheet_ShapeGroup

// Create three shapes. 
Worksheet worksheet = spreadsheetControl1.Document.Worksheets[0];
Shape shape1 = worksheet.Shapes.AddShape(ShapeGeometryPreset.RectangularCallout, 100, 100, 300, 300);
Shape shape2 = worksheet.Shapes.AddShape(ShapeGeometryPreset.RegularPentagon, 450, 0, 300, 300);
Shape shape3 = worksheet.Shapes.AddTextBox(300, 500, 200, 200, "Shape Text");

// Combine them into a shape group.
Shape shapeGroup = worksheet.Shapes.GroupShapes(new Shape[] { shape1, shape2, shape3 });
See Also