Skip to main content
.NET Framework 4.5.2+

ShapeCollection.InsertTextBox(DocumentPosition) Method

Inserts a text box in the document.

Namespace: DevExpress.XtraRichEdit.API.Native

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

Declaration

Shape InsertTextBox(
    DocumentPosition pos
)

Parameters

Name Type Description
pos DocumentPosition

The position of the text box’s anchor.

Returns

Type Description
Shape

The text box embedded in the document.

Remarks

The InsertTextBox method places a text box at the beginning of the page that contains the text box’s anchor. Use the Shape.ShapeFormat.TextBox.Document property to access and modify text box content.

Document document = wordProcessor.Document;
document.AppendText("Line One\nLine Two\nLine Three");
Shape myTextBox = document.Shapes.InsertTextBox(document.CreatePosition(15));
myTextBox.HorizontalAlignment = ShapeHorizontalAlignment.Center;
// Fill the text box with a color.
myTextBox.Fill.Color = System.Drawing.Color.WhiteSmoke;
// Draw a border around the text box.
myTextBox.Line.Color = System.Drawing.Color.Black;
myTextBox.Line.Thickness = 1;
// Modify text box content.
SubDocument textBoxDocument = myTextBox.ShapeFormat.TextBox.Document;
textBoxDocument.AppendText("Text box");
CharacterProperties cp = textBoxDocument.BeginUpdateCharacters(textBoxDocument.Range.Start, 4);
cp.ForeColor = System.Drawing.Color.Orange;
cp.FontSize = 24;
textBoxDocument.EndUpdateCharacters(cp);

The following code snippets (auto-collected from DevExpress Examples) contain references to the InsertTextBox(DocumentPosition) method.

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