Class WTextBoxFormat
Represents the formatting options of the text box such as colors and lines, size, etc.
Implements
Inherited Members
Namespace: Syncfusion.DocIO.DLS
Assembly: Syncfusion.DocIO.Base.dll
Syntax
public class WTextBoxFormat : FormatBase, IXDLSSerializableExamples
private void Button1_Click(System.Object sender, System.EventArgs e)
{
    //Create a new Word document 
    WordDocument document = new WordDocument();
    //Add new section to the document
    IWSection section = document.AddSection();
    //Add new paragraph to the section
    IWParagraph paragraph = section.AddParagraph();
    //Append new textbox to the paragraph
    IWTextBox textbox = paragraph.AppendTextBox(150, 75);
    //Add new text to the textbox body
    IWParagraph textboxParagraph = textbox.TextBoxBody.AddParagraph();
    textboxParagraph.AppendText("Text inside text box");
    //Set fill color, line width, line dashing and line style for textbox
    textbox.TextBoxFormat.FillColor = Color.LightGreen;
    textbox.TextBoxFormat.LineWidth = 2;
    textbox.TextBoxFormat.LineDashing = LineDashing.Dash;
    textbox.TextBoxFormat.LineStyle = TextBoxLineStyle.Double;
    //Apply textbox text direction
    textbox.TextBoxFormat.TextDirection = Syncfusion.DocIO.DLS.TextDirection.VerticalTopToBottom;
    //Set text wrapping style and type
    textbox.TextBoxFormat.TextWrappingStyle = TextWrappingStyle.InFrontOfText;
    textbox.TextBoxFormat.TextWrappingType = TextWrappingType.Right;
    //Set horizontal and vertical position
    textbox.TextBoxFormat.HorizontalPosition = 200;
    textbox.TextBoxFormat.VerticalPosition = 200;
    //Set horizontal and vertical origin
    textbox.TextBoxFormat.VerticalOrigin = VerticalOrigin.Margin;
    textbox.TextBoxFormat.HorizontalOrigin = HorizontalOrigin.Page;
    //Set top and bottom margin values
    textbox.TextBoxFormat.InternalMargin.Bottom = 5f;
    textbox.TextBoxFormat.InternalMargin.Top = 5f;
    //Set horizontal and vertical alignment
    textbox.TextBoxFormat.VerticalAlignment = ShapeVerticalAlignment.Bottom;
    textbox.TextBoxFormat.HorizontalAlignment = ShapeHorizontalAlignment.Center;            
    //Save and close the Word document
    document.Save("Sample.docx", FormatType.Docx);
    document.Close();
}Private Sub button_Click(sender As Object, e As EventArgs)
    'Create a new Word document 
    Dim document As New WordDocument()
    'Add new section to the document
    Dim section As IWSection = document.AddSection()
    'Add new paragraph to the section
    Dim paragraph As IWParagraph = section.AddParagraph()
    'Append new textbox to the paragraph
    Dim textbox As IWTextBox = paragraph.AppendTextBox(150, 75)
    'Add new text to the textbox body
    Dim textboxParagraph As IWParagraph = textbox.TextBoxBody.AddParagraph()
    textboxParagraph.AppendText("Text inside text box")
    'Set fill color, line width, line dashing and line style for textbox
    textbox.TextBoxFormat.FillColor = Color.LightGreen
    textbox.TextBoxFormat.LineWidth = 2
    textbox.TextBoxFormat.LineDashing = LineDashing.Dash
    textbox.TextBoxFormat.LineStyle = TextBoxLineStyle.[Double]
    'Apply textbox text direction
    textbox.TextBoxFormat.TextDirection = Syncfusion.DocIO.DLS.TextDirection.VerticalTopToBottom
    'Set text wrapping style and type
    textbox.TextBoxFormat.TextWrappingStyle = TextWrappingStyle.InFrontOfText
    textbox.TextBoxFormat.TextWrappingType = TextWrappingType.Right
    'Set horizontal and vertical position
    textbox.TextBoxFormat.HorizontalPosition = 200
    textbox.TextBoxFormat.VerticalPosition = 200
    'Set horizontal and vertical origin
    textbox.TextBoxFormat.VerticalOrigin = VerticalOrigin.Margin
    textbox.TextBoxFormat.HorizontalOrigin = HorizontalOrigin.Page
    'Set top and bottom margin values
    textbox.TextBoxFormat.InternalMargin.Bottom = 5.0F
    textbox.TextBoxFormat.InternalMargin.Top = 5.0F
    'Set horizontal and vertical alignment
    textbox.TextBoxFormat.VerticalAlignment = ShapeVerticalAlignment.Bottom
    textbox.TextBoxFormat.HorizontalAlignment = ShapeHorizontalAlignment.Center
    'Save and close the Word document
    document.Save("Sample.docx", FormatType.Docx)
    document.Close()
End SubConstructors
WTextBoxFormat(WordDocument)
Initializes a new instance of the WTextBoxFormat class with the specified WordDocument instance.
Declaration
public WTextBoxFormat(WordDocument doc)Parameters
| Type | Name | Description | 
|---|---|---|
| WordDocument | doc | The WordDocument instance. | 
Properties
AllowOverlap
Gets or sets a value indicating whether this textbox can overlap other textboxes.
Declaration
public bool AllowOverlap { get; set; }Property Value
| Type | Description | 
|---|---|
| System.Boolean | 
 | 
Remarks
The default value is true.
Examples
    //Creates a new Word document
    WordDocument document = new WordDocument();
    //Adds new section to the document
    IWSection section = document.AddSection();
    //Adds new paragraph to the section
    IWParagraph paragraph = section.AddParagraph();
    //Appends new textbox to the paragraph
    IWTextBox textbox = paragraph.AppendTextBox(150, 50);
    //Adds new text to the textbox body
    IWParagraph textboxParagraph = textbox.TextBoxBody.AddParagraph();
    textboxParagraph.AppendText("Text inside text box text inside text box text inside text box.");
    //Allow the textbox to overlap other textboxes
    textbox.TextBoxFormat.AllowOverlap = true;
    //Save and close the Word document
    document.Save("Sample.docx", FormatType.Docx);
    document.Close();    'Creates a new Word document
    Dim document As New WordDocument()
    'Adds new section to the document
    Dim section As IWSection = document.AddSection()
    'Adds new paragraph to the section
    Dim paragraph As IWParagraph = section.AddParagraph()
    'Appends new textbox to the paragraph
    Dim textbox As IWTextBox = paragraph.AppendTextBox(150, 50)
    'Adds new text to the textbox body
    Dim textboxParagraph As IWParagraph = textbox.TextBoxBody.AddParagraph()
    textboxParagraph.AppendText("Text inside text box text inside text box text inside text box.")
    'Allow the textbox to overlap other textboxes
    textbox.TextBoxFormat.AllowOverlap = True
    'Save and close the Word document
    document.Save("Sample.docx", FormatType.Docx)
    document.Close()AutoFit
Gets or set a value indicating whether the TextBox is sized automatically based on the contents.
Declaration
public bool AutoFit { get; set; }Property Value
| Type | Description | 
|---|---|
| System.Boolean | 
 | 
Remarks
The default value is false.
Examples
    //Creates a new Word document
    WordDocument document = new WordDocument();
    //Adds new section to the document
    IWSection section = document.AddSection();
    //Adds new paragraph to the section
    IWParagraph paragraph = section.AddParagraph();
    //Appends new textbox to the paragraph
    IWTextBox textbox = paragraph.AppendTextBox(150, 50);
    //Adds new text to the textbox body
    IWParagraph textboxParagraph = textbox.TextBoxBody.AddParagraph();
    textboxParagraph.AppendText("Text inside text box text inside text box text inside text box.");
    //Resize the textbox based on its contents
    textbox.TextBoxFormat.AutoFit = true;
    //Save and close the Word document
    document.Save("Sample.docx", FormatType.Docx);
    document.Close();    'Creates a new Word document
    Dim document As New WordDocument()
    'Adds new section to the document
    Dim section As IWSection = document.AddSection()
    'Adds new paragraph to the section
    Dim paragraph As IWParagraph = section.AddParagraph()
    'Appends new textbox to the paragraph
    Dim textbox As IWTextBox = paragraph.AppendTextBox(150, 50)
    'Adds new text to the textbox body
    Dim textboxParagraph As IWParagraph = textbox.TextBoxBody.AddParagraph()
    textboxParagraph.AppendText("Text inside text box text inside text box text inside text box.")
    'Resize the textbox based on its contents
    textbox.TextBoxFormat.AutoFit = True
    'Save and close the Word document
    document.Save("Sample.docx", FormatType.Docx)
    document.Close()FillColor
Gets or sets the fill color for the text box.
Declaration
public Color FillColor { get; set; }Property Value
| Type | Description | 
|---|---|
| System.Drawing.Color | The System.Drawing.Color that specifies the fill color. | 
FillEfects
Gets the background fill effects of the text box.
Declaration
public Background FillEfects { get; }Property Value
| Type | Description | 
|---|---|
| Background | The Background instance that specifies the fill effects. | 
FlipHorizontal
Gets or sets a Horizontal flipping of TextBox.
Declaration
public bool FlipHorizontal { get; set; }Property Value
| Type | Description | 
|---|---|
| System.Boolean | 
 | 
Remarks
This property returns True if the specified textbox is flipped around the horizontal axis, and False if not.
Examples
The following code example demonstrates how to gets or sets the horizontal flip to textbox.
    //Creates a new Word document 
    WordDocument document = new WordDocument();
    //Adds new section to the document
    IWSection section = document.AddSection();
    //Adds new paragraph to the section
    IWParagraph paragraph = section.AddParagraph();
    //Appends new textbox to the paragraph
    IWTextBox textbox = paragraph.AppendTextBox(150, 75);
    //Adds new text to the textbox body
    IWParagraph textboxParagraph = textbox.TextBoxBody.AddParagraph();
    textboxParagraph.AppendText("Text inside text box");
    //Sets horizontal flip to the textbox
    textbox.TextBoxFormat.FlipHorizontal = true;
    //Saves and closes the Word document
    document.Save("Sample.docx", FormatType.Docx);
    document.Close();    'Creates a new Word document 
    Dim document As WordDocument = New WordDocument
    'Adds new section to the document
    Dim section As IWSection = document.AddSection
    'Adds new paragraph to the section
    Dim paragraph As IWParagraph = section.AddParagraph
    'Appends new textbox to the paragraph
    Dim textbox As IWTextBox = paragraph.AppendTextBox(150, 75)
    'Adds new text to the textbox body
    Dim textboxParagraph As IWParagraph = textbox.TextBoxBody.AddParagraph
    textboxParagraph.AppendText("Text inside text box")
    'Sets horizontal flip to the textbox
    textbox.TextBoxFormat.FlipHorizontal = True
    'Saves and closes the Word document
    document.Save("Sample.docx", FormatType.Docx)
    document.Close()FlipVertical
Gets or sets a Vertical flipping of TextBox.
Declaration
public bool FlipVertical { get; set; }Property Value
| Type | Description | 
|---|---|
| System.Boolean | 
 | 
Remarks
This property returns True if the specified textbox is flipped around the vertical axis, and False if not.
Examples
The following code example demonstrates how to gets or sets the vertical flip to textbox.
    //Creates a new Word document 
    WordDocument document = new WordDocument();
    //Adds new section to the document
    IWSection section = document.AddSection();
    //Adds new paragraph to the section
    IWParagraph paragraph = section.AddParagraph();
    //Appends new textbox to the paragraph
    IWTextBox textbox = paragraph.AppendTextBox(150, 75);
    //Adds new text to the textbox body
    IWParagraph textboxParagraph = textbox.TextBoxBody.AddParagraph();
    textboxParagraph.AppendText("Text inside text box");
    //Sets vertical flip to the textbox
    textbox.TextBoxFormat.FlipVertical = true;
    //Saves and closes the Word document
    document.Save("Sample.docx", FormatType.Docx);
    document.Close();    'Creates a new Word document 
    Dim document As WordDocument = New WordDocument
    'Adds new section to the document
    Dim section As IWSection = document.AddSection
    'Adds new paragraph to the section
    Dim paragraph As IWParagraph = section.AddParagraph
    'Appends new textbox to the paragraph
    Dim textbox As IWTextBox = paragraph.AppendTextBox(150, 75)
    'Adds new text to the textbox body
    Dim textboxParagraph As IWParagraph = textbox.TextBoxBody.AddParagraph
    textboxParagraph.AppendText("Text inside text box")
    'Sets vertical flip to the textbox
    textbox.TextBoxFormat.FlipVertical = True
    'Saves and closes the Word document
    document.Save("Sample.docx", FormatType.Docx)
    document.Close()Height
Gets or sets the height(in points) of the text box.
Declaration
public float Height { get; set; }Property Value
| Type | Description | 
|---|---|
| System.Single | The float that specifies the height. | 
HeightOrigin
Gets or sets the vertical height origin value.
Declaration
public HeightOrigin HeightOrigin { get; set; }Property Value
| Type | Description | 
|---|---|
| HeightOrigin | The HeightOrigin member that specifies the height origin value. | 
HorizontalAlignment
Gets or sets the horizontal alignment of the text box.
Declaration
public ShapeHorizontalAlignment HorizontalAlignment { get; set; }Property Value
| Type | Description | 
|---|---|
| ShapeHorizontalAlignment | ShapeHorizontalAlignment member that specifies the horizontal alignment. | 
Remarks
If the alignment is set as None, then the text box is explicitly positioned using position properties. Otherwise it is positioned according to the alignment specified. The position of the object is relative to HorizontalOrigin.
HorizontalOrigin
Gets or sets the horizontal origin of the text box.
Declaration
public HorizontalOrigin HorizontalOrigin { get; set; }Property Value
| Type | Description | 
|---|---|
| HorizontalOrigin | The HorizontalOrigin member that specifies the horizontal origin value. | 
HorizontalPosition
Gets or sets the horizontal position of the text box.
Declaration
public float HorizontalPosition { get; set; }Property Value
| Type | Description | 
|---|---|
| System.Single | The float specifies the horizontal position. | 
LineColor
Gets or sets the line color of the text box.
Declaration
public Color LineColor { get; set; }Property Value
| Type | Description | 
|---|---|
| System.Drawing.Color | The System.Drawing.Color that specifies the line color. | 
LineDashing
Gets or sets the line dashing style for the text box.
Declaration
public LineDashing LineDashing { get; set; }Property Value
| Type | Description | 
|---|---|
| LineDashing | The LineDashing member that specifies the line dashing style. | 
LineStyle
Gets or sets the line style for the text box.
Declaration
public TextBoxLineStyle LineStyle { get; set; }Property Value
| Type | Description | 
|---|---|
| TextBoxLineStyle | The TextBoxLineStyle member that specifies the line style. | 
LineWidth
Gets or sets the line width of the text box.
Declaration
public float LineWidth { get; set; }Property Value
| Type | Description | 
|---|---|
| System.Single | The float that specifies the line width. | 
NoLine
Gets or sets a value indicating whether the textbox has no line around its shape.
Declaration
public bool NoLine { get; set; }Property Value
| Type | Description | 
|---|---|
| System.Boolean | True if the textbox has no line; otherwise, false. | 
Rotation
Gets or sets the textbox rotation in degree.
Declaration
public float Rotation { get; set; }Property Value
| Type | Description | 
|---|---|
| System.Single | The float that specifies the rotation value of the textbox. | 
Remarks
A positive value indicates clockwise rotation; a negative value indicates counterclockwise rotation.
Examples
The following code example demonstrates how to gets or sets the rotation value of textbox in degree.
    //Creates a new Word document 
    WordDocument document = new WordDocument();
    //Adds new section to the document
    IWSection section = document.AddSection();
    //Adds new paragraph to the section
    IWParagraph paragraph = section.AddParagraph();
    //Appends new textbox to the paragraph
    IWTextBox textbox = paragraph.AppendTextBox(150, 75);
    //Adds new text to the textbox body
    IWParagraph textboxParagraph = textbox.TextBoxBody.AddParagraph();
    textboxParagraph.AppendText("Text inside text box");
    //Sets textbox rotation in degree  
    textbox.TextBoxFormat.Rotation = 90;
    //Saves and closes the Word document
    document.Save("Sample.docx", FormatType.Docx);
    document.Close();    'Creates a new Word document 
    Dim document As WordDocument = New WordDocument
    'Adds new section to the document
    Dim section As IWSection = document.AddSection
    'Adds new paragraph to the section
    Dim paragraph As IWParagraph = section.AddParagraph
    'Appends new textbox to the paragraph
    Dim textbox As IWTextBox = paragraph.AppendTextBox(150, 75)
    'Adds new text to the textbox body
    Dim textboxParagraph As IWParagraph = textbox.TextBoxBody.AddParagraph
    textboxParagraph.AppendText("Text inside text box")
    'Sets textbox rotation in degree  
    textbox.TextBoxFormat.Rotation = 90
    'Saves and closes the Word document
    document.Save("Sample.docx", FormatType.Docx)
    document.Close()TextDirection
Gets or sets the text direction for the text box.
Declaration
public TextDirection TextDirection { get; set; }Property Value
| Type | Description | 
|---|---|
| TextDirection | The TextDirection member that specifies the text direction type. | 
TextVerticalAlignment
Gets or sets vertical alignment of the text in textbox.
Declaration
public VerticalAlignment TextVerticalAlignment { get; set; }Property Value
| Type | Description | 
|---|---|
| VerticalAlignment | The VerticalAlignment member that specifies the text vertical alignment. | 
Remarks
Vertical text alignment for textbox is applicable for DOCX format only.
Examples
    //Creates a new Word document
    WordDocument document = new WordDocument();
    //Adds new section to the document
    IWSection section = document.AddSection();
    //Adds new paragraph to the section
    IWParagraph paragraph = section.AddParagraph();
    //Appends new textbox to the paragraph
    IWTextBox textbox = paragraph.AppendTextBox(150, 50);
    //Adds new text to the textbox body
    IWParagraph textboxParagraph = textbox.TextBoxBody.AddParagraph();
    textboxParagraph.AppendText("Text inside text box");
    //Sets vertical alignment of the text
    textbox.TextBoxFormat.TextVerticalAlignment = VerticalAlignment.Bottom;
    //Save and close the Word document
    document.Save("Sample.docx", FormatType.Docx);
    document.Close();    'Creates a new Word document
    Dim document As New WordDocument()
    'Adds new section to the document
    Dim section As IWSection = document.AddSection()
    'Adds new paragraph to the section
    Dim paragraph As IWParagraph = section.AddParagraph()
    'Appends new textbox to the paragraph
    Dim textbox As IWTextBox = paragraph.AppendTextBox(150, 50)
    'Adds new text to the textbox body
    Dim textboxParagraph As IWParagraph = textbox.TextBoxBody.AddParagraph()
    textboxParagraph.AppendText("Text inside text box")
    'Sets vertical alignment of the text
    textbox.TextBoxFormat.TextVerticalAlignment = VerticalAlignment.Bottom
    'Save and close the Word document
    document.Save("Sample.docx", FormatType.Docx)
    document.Close()TextWrappingStyle
Gets or sets the text Wrapping style of the text box.
Declaration
public TextWrappingStyle TextWrappingStyle { get; set; }Property Value
| Type | Description | 
|---|---|
| TextWrappingStyle | The TextWrappingStyle member that specifies the text wrapping style. | 
TextWrappingType
Gets or sets the text wrapping type for the text box.
Declaration
public TextWrappingType TextWrappingType { get; set; }Property Value
| Type | Description | 
|---|---|
| TextWrappingType | The TextWrappingType member that specifies the wrapping type. | 
VerticalAlignment
Gets or sets the vertical alignment of the text box.
Declaration
public ShapeVerticalAlignment VerticalAlignment { get; set; }Property Value
| Type | Description | 
|---|---|
| ShapeVerticalAlignment | ShapeVerticalAlignment member that specifies the vertical alignment. | 
Remarks
If the alignment is set as None, then the text box is explicitly positioned using position properties. Otherwise it is positioned according to the alignment specified. The position of the object is relative to VerticalOrigin.
VerticalOrigin
Gets or sets the vertical origin of the text box.
Declaration
public VerticalOrigin VerticalOrigin { get; set; }Property Value
| Type | Description | 
|---|---|
| VerticalOrigin | The VerticalOrigin member that specifies the vertical origin value. | 
VerticalPosition
Gets or sets the vertical position of the text box.
Declaration
public float VerticalPosition { get; set; }Property Value
| Type | Description | 
|---|---|
| System.Single | The float specifies the vertical position. | 
Width
Gets or sets the width(in points) of the text box.
Declaration
public float Width { get; set; }Property Value
| Type | Description | 
|---|---|
| System.Single | The float that specifies the width. | 
WidthOrigin
Gets or sets the horizontal width origin value.
Declaration
public WidthOrigin WidthOrigin { get; set; }Property Value
| Type | Description | 
|---|---|
| WidthOrigin | The WidthOrigin member that specifies the width origin value. | 
Methods
ClearFormatting()
Clears the textbox format applied
Declaration
public override void ClearFormatting()Overrides
Clone()
Creates a duplicate copy of the text box format object.
Declaration
public WTextBoxFormat Clone()Returns
| Type | Description | 
|---|---|
| WTextBoxFormat | The reference to the newly created object. | 
GetDefValue(Int32)
Returns the default text box values.
Declaration
protected override object GetDefValue(int key)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Int32 | key | The integer that specifies the key. | 
Returns
| Type | Description | 
|---|---|
| System.Object | Null (don't use keys ). | 
Overrides
ReadXmlAttributes(IXDLSAttributeReader)
Reads object data from xml attributes.
Declaration
protected override void ReadXmlAttributes(IXDLSAttributeReader reader)Parameters
| Type | Name | Description | 
|---|---|---|
| IXDLSAttributeReader | reader | The IXDLSAttributeReader object. | 
Overrides
WriteXmlAttributes(IXDLSAttributeWriter)
Writes object data as xml attributes.
Declaration
protected override void WriteXmlAttributes(IXDLSAttributeWriter writer)Parameters
| Type | Name | Description | 
|---|---|---|
| IXDLSAttributeWriter | writer | The IXDLSAttributeWriter object. |