ShapeCollection.InsertTextBox(DocumentPosition) Method
Inserts a text box.
Namespace: DevExpress.XtraRichEdit.API.Native
Assembly: DevExpress.RichEdit.v19.2.Core.dll
Declaration
Parameters
Name | Type | Description |
---|---|---|
pos | DocumentPosition | The position of a text box’s anchor. |
Returns
Type | Description |
---|---|
Shape | A shape with a text. |
Remarks
The InsertTextBox method positions a floating text box at the beginning of the first paragraph on the page that contains the floating object’s anchor.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/word-processing-document-api-examples-t418535
Document document = server.Document;
document.AppendText("Line One\nLine Two\nLine Three");
Shape myTextBox = document.Shapes.InsertTextBox(document.CreatePosition(15));
myTextBox.HorizontalAlignment = ShapeHorizontalAlignment.Center;
// Specify the text box background 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.TextBox.Document;
textBoxDocument.AppendText("TextBox Text");
CharacterProperties cp = textBoxDocument.BeginUpdateCharacters(textBoxDocument.Range.Start, 7);
cp.ForeColor = System.Drawing.Color.Orange;
cp.FontSize = 24;
textBoxDocument.EndUpdateCharacters(cp);
Related GitHub Examples
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.