Back to Devexpress

Shape.TextWrapping Property

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-shape-61dd8033.md

latest11.0 KB
Original Source

Shape.TextWrapping Property

Specifies how a shape is surrounded by text.

Namespace : DevExpress.XtraRichEdit.API.Native

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

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
TextWrappingType TextWrapping { get; set; }
vb
Property TextWrapping As TextWrappingType

Property Value

TypeDescription
TextWrappingType

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

|

Available values:

NameDescription
Square

The text wraps around the rectangular borders of the shape.

| | 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.

| | BehindText |

The text is displayed over the shape.

| | InFrontOfText |

The text is displayed behind the shape.

| | 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.

csharp
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;
vb
Dim document As 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.
Dim rectangle As Shape = 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.

csharp
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;
vb
Dim document As 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.
Dim rectangle As Shape = 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.

word-document-api-insert-inline-pictures/CS/Program.cs#L27

csharp
Shape imageFromFile = document.Shapes.InsertPicture(pos, DocumentImageSource.FromFile("Pictures\\ReadersChoice.png"));
imageFromFile.TextWrapping = TextWrappingType.InLineWithText;

winforms-richedit-document-api/CS/RichEditAPISample/CodeExamples/Shapes.cs#L46

csharp
myPicture.ZOrder = document.Shapes[0].ZOrder - 1;
myPicture.TextWrapping = TextWrappingType.BehindText;
#endregion #ChangeZorderAndWrapping

wpf-richedit-document-api/CS/DXRichEditControlAPISample/CodeExamples/ShapesActions.cs#L57

csharp
myPicture.ZOrder = document.Shapes[0].ZOrder - 1;
myPicture.TextWrapping = TextWrappingType.BehindText;
#endregion #ChangeZorderAndWrapping

word-document-api-examples/CS/CodeExamples/ShapesActions.cs#L91

csharp
// Display document text over the picture.
    myPicture.TextWrapping = TextWrappingType.BehindText;
}

word-document-api-create-master-detail-report/CS/Program.cs#L73

csharp
Shape shape = pictureProcessor.Document.Shapes.InsertPicture(pictureProcessor.Document.Range.End, DocumentImageSource.FromStream(imageStream));
shape.TextWrapping = TextWrappingType.InLineWithText;
e.Value = pictureProcessor;

word-document-api-insert-inline-pictures/VB/Program.vb#L20

vb
Dim imageFromFile As Shape = document.Shapes.InsertPicture(pos, DocumentImageSource.FromFile("Pictures\ReadersChoice.png"))
imageFromFile.TextWrapping = TextWrappingType.InLineWithText

winforms-richedit-document-api/VB/RichEditAPISample/CodeExamples/Shapes.vb#L42

vb
myPicture.ZOrder = document.Shapes(CInt((0))).ZOrder - 1
            myPicture.TextWrapping = DevExpress.XtraRichEdit.API.Native.TextWrappingType.BehindText
#End Region ' #ChangeZorderAndWrapping

wpf-richedit-document-api/VB/DXRichEditControlAPISample/CodeExamples/ShapesActions.vb#L49

vb
myPicture.ZOrder = document.Shapes(0).ZOrder - 1
            myPicture.TextWrapping = TextWrappingType.BehindText
' #End Region ' #ChangeZorderAndWrapping

word-document-api-examples/VB/CodeExamples/ShapesActions.vb#L76

vb
' Display document text over the picture.
    myPicture.TextWrapping = DevExpress.XtraRichEdit.API.Native.TextWrappingType.BehindText
End If

word-document-api-create-master-detail-report/VB/Program.vb#L73

vb
Dim shape As Shape = pictureProcessor.Document.Shapes.InsertPicture(pictureProcessor.Document.Range.End, DocumentImageSource.FromStream(imageStream))
shape.TextWrapping = TextWrappingType.InLineWithText
e.Value = pictureProcessor

See Also

Shape Interface

Shape Members

DevExpress.XtraRichEdit.API.Native Namespace