Back to Devexpress

ShapeCollection.InsertShape(DocumentPosition, ShapeGeometryPreset, RectangleF) Method

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-shapecollection-dot-insertshape-x28-documentposition-shapegeometrypreset-rectanglef-x29.md

latest4.0 KB
Original Source

ShapeCollection.InsertShape(DocumentPosition, ShapeGeometryPreset, RectangleF) Method

Inserts a shape at the specified position in the document.

Namespace : DevExpress.XtraRichEdit.API.Native

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

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
Shape InsertShape(
    DocumentPosition pos,
    ShapeGeometryPreset preset,
    RectangleF bounds
)
vb
Function InsertShape(
    pos As DocumentPosition,
    preset As ShapeGeometryPreset,
    bounds As RectangleF
) As Shape

Parameters

NameTypeDescription
posDocumentPosition

The position of the shape’s anchor.

| | preset | ShapeGeometryPreset |

An enumeration member that defines the shape’s geometry.

| | bounds | RectangleF |

An object that specifies the shape’s size and location (relative to the top and left edges of the page). The Document.Unit property defines the measurement units.

|

Returns

TypeDescription
Shape

The shape embedded in the document.

|

Remarks

The example below creates a rectangle and places it on the page as follows:

  • the absolute horizontal position is 1.5 inches to the right of the page;

  • the absolute vertical position is one inch below the page.

Use the following properties to customize the shape appearance:

csharp
Document document = wordProcessor.Document;
document.Unit = DevExpress.Office.DocumentUnit.Inch;
// Create a rectangle.
Shape rectangle = document.Shapes.InsertShape(document.Range.Start, ShapeGeometryPreset.Rectangle, new RectangleF(1.5f, 1f, 2f, 1.5f));
// Fill the rectangle with color.
rectangle.Fill.SetSolidFill(Color.FromArgb(0xFF, 0xEE, 0xAD));
// Format the rectangle border.
ShapeLine border = rectangle.Line;
border.Color = Color.FromArgb(0x4D, 0x64, 0x8D);
border.Thickness = 6;
border.JoinType = LineJoinType.Miter;
vb
Dim document As Document = wordProcessor.Document
document.Unit = DevExpress.Office.DocumentUnit.Inch
' Create a rectangle.
Dim rectangle As Shape = document.Shapes.InsertShape(document.Range.Start, ShapeGeometryPreset.Rectangle, New RectangleF(1.5F, 1F, 2F, 1.5F))
' Fill the rectangle with color.
rectangle.Fill.SetSolidFill(Color.FromArgb(&HFF, &HEE, &HAD))
' Format the rectangle border.
Dim border As ShapeLine = rectangle.Line
border.Color = Color.FromArgb(&H4D, &H64, &H8D)
border.Thickness = 6
border.JoinType = LineJoinType.Miter

See Also

ShapeCollection Interface

ShapeCollection Members

DevExpress.XtraRichEdit.API.Native Namespace