InsertGroupShape

InsertGroupShape(params Shape[])

Groups the shapes passed as a parameter into a new GroupShape node which is inserted into the current position.

public GroupShape InsertGroupShape(params Shape[] shapes)
ParameterTypeDescription
shapesShape[]The list of shapes to be grouped.

Remarks

The position and dimension of the new GroupShape will be calculated automatically.

VML and DML shapes cannot be grouped together.

Examples

Shows how to insert DML group shape.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Shape shape1 = builder.InsertShape(ShapeType.Rectangle, 200, 250);
shape1.Left = 20;
shape1.Top = 20;
shape1.Stroke.Color = Color.Red;

Shape shape2 = builder.InsertShape(ShapeType.Ellipse, 150, 200);
shape2.Left = 40;
shape2.Top = 50;
shape2.Stroke.Color = Color.Green;

// Dimensions for the new GroupShape node.
double left = 10;
double top = 10;
double width = 200;
double height = 300;
// Insert GroupShape node for the specified size which is inserted into the specified position.
GroupShape groupShape1 = builder.InsertGroupShape(left, top, width, height, new Shape[] { shape1, shape2 });

// Insert GroupShape node which position and dimension will be calculated automatically.
Shape shape3 = (Shape)shape1.Clone(true);
GroupShape groupShape2 = builder.InsertGroupShape(shape3);

doc.Save(ArtifactsDir + "Shape.InsertGroupShape.docx");

See Also


InsertGroupShape(double, double, double, double, params Shape[])

Groups the shapes passed as a parameter into a new GroupShape node of the specified size which is inserted into the specified position.

public GroupShape InsertGroupShape(double left, double top, double width, double height, 
    params Shape[] shapes)
ParameterTypeDescription
leftDoubleDistance in points from the origin to the left side of the group shape.
topDoubleDistance in points from the origin to the top side of the group shape.
widthDoubleThe width of the group shape in points. A negative value is not allowed.
heightDoubleThe height of the group shape in points. A negative value is not allowed.
shapesShape[]The list of shapes to be grouped.

Remarks

VML and DML shapes cannot be grouped together.

Examples

Shows how to insert DML group shape.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Shape shape1 = builder.InsertShape(ShapeType.Rectangle, 200, 250);
shape1.Left = 20;
shape1.Top = 20;
shape1.Stroke.Color = Color.Red;

Shape shape2 = builder.InsertShape(ShapeType.Ellipse, 150, 200);
shape2.Left = 40;
shape2.Top = 50;
shape2.Stroke.Color = Color.Green;

// Dimensions for the new GroupShape node.
double left = 10;
double top = 10;
double width = 200;
double height = 300;
// Insert GroupShape node for the specified size which is inserted into the specified position.
GroupShape groupShape1 = builder.InsertGroupShape(left, top, width, height, new Shape[] { shape1, shape2 });

// Insert GroupShape node which position and dimension will be calculated automatically.
Shape shape3 = (Shape)shape1.Clone(true);
GroupShape groupShape2 = builder.InsertGroupShape(shape3);

doc.Save(ArtifactsDir + "Shape.InsertGroupShape.docx");

See Also