.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

TextBox.Document Property

Provides access to text box content.

Namespace: DevExpress.XtraRichEdit.API.Native

Assembly: DevExpress.RichEdit.v21.1.Core.dll


SubDocument Document { get; }

Property Value

Type Description

An object that exposes text box content.


The example below inserts a paragraph and a picture from the main document into a text box. Use the TextBox.Document property to access and modify text box content.

Document document = server.Document;
document.LoadDocument("Documents\\Grimm.docx", DocumentFormat.OpenXml);
// Access a text box in the document.
Shape myTextBox = document.Shapes[0];
// Specify that the text box should resize to fit its content.
myTextBox.ShapeFormat.TextBox.ResizeShapeToFitText = true;
// Access text box content.
SubDocument boxedDocument = myTextBox.ShapeFormat.TextBox.Document;
int appendPosition = myTextBox.ShapeFormat.TextBox.Document.Range.End.ToInt();
// Append the second paragraph of the main document to the text box.
DocumentRange newRange = boxedDocument.AppendDocumentContent(document.Paragraphs[1].Range);
// Insert an image form the main document into the text box.
boxedDocument.Images.Insert(boxedDocument.CreatePosition(appendPosition), document.Images[0].Image.NativeImage);
// Resize the image so that its size equals the image in the main document.
boxedDocument.Images[0].Size = document.Images[0].Size;
See Also