TextBox Class
Defines attributes that specify how a text is displayed inside a shape.
Inheritance Hierarchy
SystemObject
  Aspose.Words.DrawingTextBox

Namespace: Aspose.Words.Drawing
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.12
Syntax
public class TextBox

The TextBox type exposes the following members.

Properties
  NameDescription
Public propertyCode exampleFitShapeToText
Determines whether Microsoft Word will grow the shape to fit text.
Public propertyCode exampleInternalMarginBottom
Specifies the inner bottom margin in points for a shape.
Public propertyCode exampleInternalMarginLeft
Specifies the inner left margin in points for a shape.
Public propertyCode exampleInternalMarginRight
Specifies the inner right margin in points for a shape.
Public propertyCode exampleInternalMarginTop
Specifies the inner top margin in points for a shape.
Public propertyCode exampleLayoutFlow
Determines the flow of the text layout in a shape.
Public propertyCode exampleNext
Returns or sets a TextBox that represents the next TextBox in a sequence of shapes.
Public propertyParent
Gets a parent shape for the TextBox.
Public propertyCode examplePrevious
Returns a TextBox that represents the previous TextBox in a sequence of shapes.
Public propertyCode exampleTextBoxWrapMode
Determines how text wraps inside a shape.
Public propertyCode exampleVerticalAnchor
Specifies the vertical alignment of the text within a shape.
Methods
  NameDescription
Public methodCode exampleBreakForwardLink
Breaks the link to the next TextBox.
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Public methodCode exampleIsValidLinkTarget
Determines whether this TextBox can be linked to the target Textbox.
Protected methodMemberwiseClone (Inherited from Object.)
Public methodToString (Inherited from Object.)
Remarks

Use the TextBox property to access text properties of a shape. You do not create instances of the TextBox class directly.

Examples
Shows how to insert text boxes and arrange their text.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Insert a shape that contains a TextBox
Shape textBoxShape = builder.InsertShape(ShapeType.TextBox, 150, 100);
TextBox textBox = textBoxShape.TextBox;

// Move the document builder to inside the TextBox and write text
builder.MoveTo(textBoxShape.LastParagraph);
builder.Write("Vertical text");

// Text is displayed vertically, written top to bottom
textBox.LayoutFlow = LayoutFlow.TopToBottomIdeographic;

// Move the builder out of the shape and back into the main document body
builder.MoveTo(textBoxShape.ParentParagraph);

// Insert another TextBox
textBoxShape = builder.InsertShape(ShapeType.TextBox, 150, 100);
textBox = textBoxShape.TextBox;

// Apply these values to both these members to get the parent shape to defy the dimensions we set to fit tightly around the TextBox's text
textBox.FitShapeToText = true;
textBox.TextBoxWrapMode = TextBoxWrapMode.None;

builder.MoveTo(textBoxShape.LastParagraph);
builder.Write("Text fit tightly inside textbox");

builder.MoveTo(textBoxShape.ParentParagraph);

textBoxShape = builder.InsertShape(ShapeType.TextBox, 100, 100);
textBox = textBoxShape.TextBox;

// Set margins for the textbox
textBox.InternalMarginTop = 15;
textBox.InternalMarginBottom = 15;
textBox.InternalMarginLeft = 15;
textBox.InternalMarginRight = 15;

builder.MoveTo(textBoxShape.LastParagraph);
builder.Write("Text placed according to textbox margins");

doc.Save(ArtifactsDir + "Drawing.TextBox.docx");
See Also