Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+

TextBox.Document Property

Provides access to text box content.

Namespace: DevExpress.XtraRichEdit.API.Native

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

NuGet Package: DevExpress.RichEdit.Core

Declaration

SubDocument Document { get; }

Property Value

Type Description
SubDocument

An object that exposes text box content.

Remarks

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);
boxedDocument.Paragraphs.Insert(newRange.Start);
// 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;

The following code snippets (auto-collected from DevExpress Examples) contain references to the Document 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