officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-shapeformat-f2a394bc.md
Provides access to text box content and its settings.
Namespace : DevExpress.XtraRichEdit.API.Native
Assembly : DevExpress.RichEdit.v25.2.Core.dll
NuGet Package : DevExpress.RichEdit.Core
TextBox TextBox { get; }
ReadOnly Property TextBox As TextBox
| Type | Description |
|---|---|
| TextBox |
An object that defines text box content and its settings.
|
Call the ShapeCollection.InsertTextBox method to add a text box to a document. The ShapeFormat.TextBox property allows you to specify text box content and define its settings (such as margins and alignment).
Document document = wordProcessor.Document;
document.Unit = DevExpress.Office.DocumentUnit.Inch;
// Create a text box.
Shape myTextBox = document.Shapes.InsertTextBox(document.Range.Start, new RectangleF(1.5f, 1f, 1.5f, 0.5f));
// 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.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);
Dim document As Document = wordProcessor.Document
document.Unit = DevExpress.Office.DocumentUnit.Inch
' Create a text box.
Dim myTextBox As Shape = document.Shapes.InsertTextBox(document.Range.Start, New RectangleF(1.5F, 1F, 1.5F, 0.5F))
' 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.
Dim textBoxDocument As SubDocument = myTextBox.ShapeFormat.TextBox.Document
textBoxDocument.AppendText("Text box")
Dim cp As CharacterProperties = textBoxDocument.BeginUpdateCharacters(textBoxDocument.Range.Start, 4)
cp.ForeColor = System.Drawing.Color.Orange
cp.FontSize = 24
textBoxDocument.EndUpdateCharacters(cp)
Use the following properties to determine whether an existing drawing object is a text box:
DrawingObject.ShapeFormat.HasText returns true.
The following code snippets (auto-collected from DevExpress Examples) contain references to the TextBox 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.
winforms-richedit-iterate-through-all-sub-documents/CS/SubDocumentHelper.cs#L45
foreach (Shape shape in shapes)
if (shape.ShapeFormat.TextBox != null)
subDocumentProcessor(shape.ShapeFormat.TextBox.Document);
word-document-api-iterate-through-all-sub-documents/CS/SubDocumentHelper.cs#L45
foreach (Shape shape in shapes)
if (shape.ShapeFormat.TextBox != null)
subDocumentProcessor(shape.ShapeFormat.TextBox.Document);
winforms-richedit-iterate-through-all-sub-documents/VB/SubDocumentHelper.vb#L40
For Each shape As Shape In shapes
If shape.ShapeFormat.TextBox IsNot Nothing Then subDocumentProcessor(shape.ShapeFormat.TextBox.Document)
Next
word-document-api-iterate-through-all-sub-documents/VB/SubDocumentHelper.vb#L40
For Each shape As Shape In shapes
If shape.ShapeFormat.TextBox IsNot Nothing Then subDocumentProcessor(shape.ShapeFormat.TextBox.Document)
Next
See Also