Back to Devexpress

CanvasShapeCollection.Remove(NestedShape) Method

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-canvasshapecollection-dot-remove-x28-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-nestedshape-x29.md

latest3.7 KB
Original Source

CanvasShapeCollection.Remove(NestedShape) Method

Removes the specified shape from the canvas.

Namespace : DevExpress.XtraRichEdit.API.Native

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

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
void Remove(
    NestedShape shape
)
vb
Sub Remove(
    shape As NestedShape
)

Parameters

NameTypeDescription
shapeNestedShape

A shape to remove.

|

Remarks

The following example creates a drawing canvas with three shapes and then removes the picture from the canvas:

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);
// Specify the canvas height.
canvas.Height = 1.5f;
// Access the collection of canvas items. 
var canvasItems = canvas.CanvasItems;
// Add a rectangle to the canvas.
var shape1 = canvasItems.AddShape(ShapeGeometryPreset.Rectangle, new RectangleF(0f, 0f, 2f, 1.5f));
shape1.Fill.SetSolidFill(Color.FromArgb(0xA4, 0xFF, 0xFF));
shape1.Line.Color = Color.DarkGray;
shape1.Line.Thickness = 2;
// Add a picture to the canvas.
var shape2 = canvasItems.AddPicture(DocumentImageSource.FromFile("Picture_Arrow.png"), new PointF(2.1f, 0.3f));
// Add a parallelogram to the canvas.
var shape3 = canvasItems.AddShape(ShapeGeometryPreset.Parallelogram, new RectangleF(3.8f, 0f, 2f, 1.5f));
shape3.Fill.SetSolidFill(Color.FromArgb(0xFF, 0xA5, 0xA5));
shape3.Line.Color = Color.DarkGray;
shape3.Line.Thickness = 2;
// Remove the picture from the canvas.
canvasItems.Remove(shape2);
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)
' Specify the canvas height.
canvas.Height = 1.5F
' Access the collection of canvas items. 
Dim canvasItems As CanvasShapeCollection = canvas.CanvasItems
' Add a rectangle to the canvas.
Dim shape1 As NestedShape = canvasItems.AddShape(ShapeGeometryPreset.Rectangle, New RectangleF(0F, 0F, 2F, 1.5F))
shape1.Fill.SetSolidFill(Color.FromArgb(&HA4, &HFF, &HFF))
shape1.Line.Color = Color.DarkGray
shape1.Line.Thickness = 2
' Add a picture to the canvas.
Dim shape2 As NestedShape = canvasItems.AddPicture(DocumentImageSource.FromFile("Picture_Arrow.png"), New PointF(2.1F, 0.3F))
' Add a parallelogram to the canvas.
Dim shape3 As NestedShape = canvasItems.AddShape(ShapeGeometryPreset.Parallelogram, New RectangleF(3.8F, 0F, 2F, 1.5F))
shape3.Fill.SetSolidFill(Color.FromArgb(&HFF, &HA5, &HA5))
shape3.Line.Color = Color.DarkGray
shape3.Line.Thickness = 2
' Remove the picture from the canvas.
canvasItems.Remove(shape2)

See Also

CanvasShapeCollection Interface

CanvasShapeCollection Members

DevExpress.XtraRichEdit.API.Native Namespace