TextBox.Document Property
Provides access to content of the text box.
Namespace: DevExpress.XtraRichEdit.API.Native
Assembly: DevExpress.RichEdit.v19.1.Core.dll
Declaration
Property Value
Type | Description |
---|---|
SubDocument | A SubDocument interface exposing the text box content. |
Remarks
The following code snippet illustrate how you can modify the text box content.
The following code inserts a paragraph and a picture from the main document into the text box. The TextBox.Document
property provides access to the text box content.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/word-processing-document-api-examples-t418535
Document document = server.Document;
document.LoadDocument("Documents\\Grimm.docx", DocumentFormat.OpenXml);
Shape myTextBox = document.Shapes[0];
// Allow text box resize to fit contents.
myTextBox.TextBox.HeightRule = TextBoxSizeRule.Auto;
SubDocument boxedDocument = myTextBox.TextBox.Document;
int appendPosition = myTextBox.TextBox.Document.Range.End.ToInt();
// Append the second paragraph of the main document to the boxed text.
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;
Related GitHub Examples
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.