Skip to main content

Shape.TextWrapping Property

Specifies how a shape is surrounded by text.

Namespace: DevExpress.XtraRichEdit.API.Native

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

NuGet Package: DevExpress.RichEdit.Core

Declaration

TextWrappingType TextWrapping { get; set; }

Property Value

Type Description
TextWrappingType

An enumeration member that specifies how text wraps around the shape.

Available values:

Name Description
Square

The text wraps around the rectangular borders of the shape.

WrapType-Square

Tight

The text wraps tightly around the shape. This enumeration value exists for compatibility only. Rich Text Editor interprets it as Square while rendering the document.

Through

The text wraps tightly around the shape and can fill in the transparent background space inside the shape. This enumeration value exists for compatibility only. Rich Text Editor interprets it as Square while rendering the document.

TopAndBottom

The text is displayed above and below the shape and does not wrap around the sides.

WrapType-TopAndBottom

BehindText

The text is displayed over the shape.

WrapType-BehindTheText

InFrontOfText

The text is displayed behind the shape.

WrapType-InFrontOfTheText

InLineWithText

The shape is placed in line with text.

Remarks

Use the TextWrapping property to specify whether the text wraps around, over or behind a shape.

The TextWrapping property for shapes located in a header or footer can be set only to TextWrappingType.BehindText or TextWrappingType.InFrontOfText.

Polygonal wrap modes (Through and Tight) are interpreted as Square when a document is displayed in the Rich Text Editor. These modes are available for compatibility reasons so that they are not lost when the document is resaved.

The example below demonstrates how to wrap text around a shape.

Wrap text around a rectangle

Document document = wordProcessor.Document;
document.LoadDocument("FirstLook.docx");
// Set the measurement unit to inches.
document.Unit = DevExpress.Office.DocumentUnit.Inch;

// Create a rectangle with a folded corner.
Shape rectangle = document.Shapes.InsertShape(document.CreatePosition(100), ShapeGeometryPreset.FoldedCorner);
// Center the rectangle on the page.
rectangle.RelativeHorizontalPosition = ShapeRelativeHorizontalPosition.Page;
rectangle.HorizontalAlignment = ShapeHorizontalAlignment.Center;
rectangle.RelativeVerticalPosition = ShapeRelativeVerticalPosition.Page;
rectangle.VerticalAlignment = ShapeVerticalAlignment.Center;

// Wrap text around the rectangle.
rectangle.TextWrapping = TextWrappingType.Square;

// Set the distance between the rectangle and text.
rectangle.MarginTop = 0.1f;
rectangle.MarginBottom = 0.1f;
rectangle.MarginLeft = 0.2f;
rectangle.MarginRight = 0.2f;

Inline drawing objects

Set the Shape.TextWrapping property to TextWrappingType.InLineWithText to convert a floating object to an inline shape.

The example below demonstrates how to insert an inline shape.

An inline shape

Document document = wordProcessor.Document;
// Set the measurement unit to inches.
document.Unit = DevExpress.Office.DocumentUnit.Inch;

// Append text to the document.
document.AppendText("The plus sign is a binary operator that indicates addition.");

// Create a plus sign.
Shape rectangle = document.Shapes.InsertShape(document.CreatePosition(13), ShapeGeometryPreset.Plus);
// Set the shape size.
rectangle.Size = new SizeF(0.25f, 0.25f);

// Place the shape in line with text.
rectangle.TextWrapping = TextWrappingType.InLineWithText;

The following code snippets (auto-collected from DevExpress Examples) contain references to the TextWrapping property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also