Back to Devexpress

NestedShapeCollection.AddGroup() Method

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-nestedshapecollection.md

latest9.0 KB
Original Source

NestedShapeCollection.AddGroup() Method

Adds a nested group to an existing shape group or a drawing canvas.

Namespace : DevExpress.XtraRichEdit.API.Native

Assembly : DevExpress.RichEdit.v25.2.Core.dll

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
NestedShape AddGroup()
vb
Function AddGroup As NestedShape

Returns

TypeDescription
NestedShape

The nested group.

|

Remarks

Add a Shape Group to a Drawing Canvas

Call the ShapeCollection.InsertCanvas method to add a drawing canvas to a document. Use the Shape.CanvasItems property to access the collection of canvas items. The collection’s Add methods allow you to add shapes and shape groups to the canvas.

The example below creates a drawing canvas that contains two shape groups.

csharp
Document document = wordProcessor.Document;
// Set the measurement unit to inches.
document.Unit = DevExpress.Office.DocumentUnit.Inch;
// Insert a drawing canvas.
Shape canvas = document.Shapes.InsertCanvas(document.Range.Start, new RectangleF(1f, 1f, 6.2f, 1f));
// Access the collection of canvas items. 
var canvasItems = canvas.CanvasItems;
// Add the first shape group to the canvas.
var group1 = canvasItems.AddGroup();
// Add shapes to the group.
var arrow1 = group1.GroupItems.AddShape(ShapeGeometryPreset.NotchedRightArrow, new RectangleF(0f, 0f, 1.7f, 1f));
arrow1.Fill.SetSolidFill(Color.FromArgb(0xA4, 0xFF, 0xFF));
arrow1.Line.Color = Color.DarkGray;
arrow1.Line.Thickness = 1;
var arrow2 = group1.GroupItems.AddShape(ShapeGeometryPreset.NotchedRightArrow, new RectangleF(1.5f, 0f, 1.7f, 1f));
arrow2.Fill.SetSolidFill(Color.FromArgb(0xA1, 0xF9, 0xA1));
arrow2.Line.Color = Color.DarkGray;
arrow2.Line.Thickness = 1;
// Add the second shape group to the canvas.
var group2 = canvasItems.AddGroup();
// Add shapes to the group.
var arrow3 = group2.GroupItems.AddShape(ShapeGeometryPreset.NotchedRightArrow, new RectangleF(3f, 0f, 1.7f, 1f));
arrow3.Fill.SetSolidFill(Color.FromArgb(0xFF, 0xA5, 0xA5));
arrow3.Line.Color = Color.DarkGray;
arrow3.Line.Thickness = 1;
var arrow4 = group2.GroupItems.AddShape(ShapeGeometryPreset.NotchedRightArrow, new RectangleF(4.5f, 0f, 1.7f, 1f));
arrow4.Fill.SetSolidFill(Color.FromArgb(0xFF, 0xC9, 0xA5));
arrow4.Line.Color = Color.DarkGray;
arrow4.Line.Thickness = 1;
vb
Dim document As Document = wordProcessor.Document
' Set the measurement unit to inches.
document.Unit = DevExpress.Office.DocumentUnit.Inch
' Insert a drawing canvas.
Dim canvas As Shape = document.Shapes.InsertCanvas(document.Range.Start, New RectangleF(1F, 1F, 6.2F, 1F))
' Access the collection of canvas items. 
Dim canvasItems As CanvasShapeCollection = canvas.CanvasItems
' Add the first shape group to the canvas.
Dim group1 As NestedShape = canvasItems.AddGroup()
' Add shapes to the group.
Dim arrow1 As NestedShape = group1.GroupItems.AddShape(ShapeGeometryPreset.NotchedRightArrow, New RectangleF(0F, 0F, 1.7F, 1F))
arrow1.Fill.SetSolidFill(Color.FromArgb(&HA4, &HFF, &HFF))
arrow1.Line.Color = Color.DarkGray
arrow1.Line.Thickness = 1
Dim arrow2 As NestedShape = group1.GroupItems.AddShape(ShapeGeometryPreset.NotchedRightArrow, New RectangleF(1.5F, 0F, 1.7F, 1F))
arrow2.Fill.SetSolidFill(Color.FromArgb(&HA1, &HF9, &HA1))
arrow2.Line.Color = Color.DarkGray
arrow2.Line.Thickness = 1
' Add the second shape group to the canvas.
Dim group2 As NestedShape = canvasItems.AddGroup()
' Add shapes to the group.
Dim arrow3 As NestedShape = group2.GroupItems.AddShape(ShapeGeometryPreset.NotchedRightArrow, New RectangleF(3F, 0F, 1.7F, 1F))
arrow3.Fill.SetSolidFill(Color.FromArgb(&HFF, &HA5, &HA5))
arrow3.Line.Color = Color.DarkGray
arrow3.Line.Thickness = 1
Dim arrow4 As NestedShape = group2.GroupItems.AddShape(ShapeGeometryPreset.NotchedRightArrow, New RectangleF(4.5F, 0F, 1.7F, 1F))
arrow4.Fill.SetSolidFill(Color.FromArgb(&HFF, &HC9, &HA5))
arrow4.Line.Color = Color.DarkGray
arrow4.Line.Thickness = 1

Add a Nested Group to an Existing Shape Group

Call the ShapeCollection.InsertGroup method to create a shape group. The Shape.GroupItems property returns the collection of group items. Use the collection’s Add methods to add shapes and nested groups to the newly created group.

The example below creates a shape group with two nested groups.

csharp
Document document = wordProcessor.Document;
// Set the measurement unit to inches.
document.Unit = DevExpress.Office.DocumentUnit.Inch;
// Insert a shape group.
Shape group = document.Shapes.InsertGroup(document.Range.Start);
// Specify the group position relative to the left and top edges of the page. 
group.Offset = new PointF(1f, 1f);
// Access the collection of group items. 
var groupItems = group.GroupItems;
// Add the first nested group to the shape group.
var group1 = groupItems.AddGroup();
// Add shapes to the nested group.
var arrow1 = group1.GroupItems.AddShape(ShapeGeometryPreset.NotchedRightArrow, new RectangleF(0f, 0f, 1.7f, 1f));
arrow1.Fill.SetSolidFill(Color.FromArgb(0xA4, 0xFF, 0xFF));
arrow1.Line.Color = Color.DarkGray;
arrow1.Line.Thickness = 1;
var arrow2 = group1.GroupItems.AddShape(ShapeGeometryPreset.NotchedRightArrow, new RectangleF(1.5f, 0f, 1.7f, 1f));
arrow2.Fill.SetSolidFill(Color.FromArgb(0xA1, 0xF9, 0xA1));
arrow2.Line.Color = Color.DarkGray;
arrow2.Line.Thickness = 1;
// Add the second nested group to the shape group.
var group2 = groupItems.AddGroup();
// Add shapes to the nested group.
var arrow3 = group2.GroupItems.AddShape(ShapeGeometryPreset.NotchedRightArrow, new RectangleF(3f, 0f, 1.7f, 1f));
arrow3.Fill.SetSolidFill(Color.FromArgb(0xFF, 0xA5, 0xA5));
arrow3.Line.Color = Color.DarkGray;
arrow3.Line.Thickness = 1;
var arrow4 = group2.GroupItems.AddShape(ShapeGeometryPreset.NotchedRightArrow, new RectangleF(4.5f, 0f, 1.7f, 1f));
arrow4.Fill.SetSolidFill(Color.FromArgb(0xFF, 0xC9, 0xA5));
arrow4.Line.Color = Color.DarkGray;
arrow4.Line.Thickness = 1;
vb
Dim document As Document = wordProcessor.Document
' Set the measurement unit to inches.
document.Unit = DevExpress.Office.DocumentUnit.Inch
' Insert a shape group.
Dim group As Shape = document.Shapes.InsertGroup(document.Range.Start)
' Specify the group position relative to the left and top edges of the page. 
group.Offset = New PointF(1F, 1F)
' Access the collection of group items. 
Dim groupItems As GroupShapeCollection = group.GroupItems
' Add the first nested group to the shape group.
Dim group1 As NestedShape = groupItems.AddGroup()
' Add shapes to the nested group.
Dim arrow1 As NestedShape = group1.GroupItems.AddShape(ShapeGeometryPreset.NotchedRightArrow, New RectangleF(0F, 0F, 1.7F, 1F))
arrow1.Fill.SetSolidFill(Color.FromArgb(&HA4, &HFF, &HFF))
arrow1.Line.Color = Color.DarkGray
arrow1.Line.Thickness = 1
Dim arrow2 As NestedShape = group1.GroupItems.AddShape(ShapeGeometryPreset.NotchedRightArrow, New RectangleF(1.5F, 0F, 1.7F, 1F))
arrow2.Fill.SetSolidFill(Color.FromArgb(&HA1, &HF9, &HA1))
arrow2.Line.Color = Color.DarkGray
arrow2.Line.Thickness = 1
' Add the second nested group to the shape group.
Dim group2 As NestedShape = groupItems.AddGroup()
' Add shapes to the nested group.
Dim arrow3 As NestedShape = group2.GroupItems.AddShape(ShapeGeometryPreset.NotchedRightArrow, New RectangleF(3F, 0F, 1.7F, 1F))
arrow3.Fill.SetSolidFill(Color.FromArgb(&HFF, &HA5, &HA5))
arrow3.Line.Color = Color.DarkGray
arrow3.Line.Thickness = 1
Dim arrow4 As NestedShape = group2.GroupItems.AddShape(ShapeGeometryPreset.NotchedRightArrow, New RectangleF(4.5F, 0F, 1.7F, 1F))
arrow4.Fill.SetSolidFill(Color.FromArgb(&HFF, &HC9, &HA5))
arrow4.Line.Color = Color.DarkGray
arrow4.Line.Thickness = 1

See Also

NestedShapeCollection Interface

NestedShapeCollection Members

DevExpress.XtraRichEdit.API.Native Namespace