Xceed Words for .NET v3.0 Documentation
AddTextBox Method
Example 


Xceed.Document.NET Assembly > Xceed.Document.NET Namespace > Document Class : AddTextBox Method
The width of the TextBox (in points).
The height of the TextBox (in points).
The text to use in the TextBox. If not defined, an empty paragraph is used.
The Formatting to use for the text in the TextBox.
The Color used to fill the TextBox. If not defined, white is used.
The Color used for the outline of the TextBox. If not defined, black is used.
The width used for the outline of the TextBox (in points). If not defined, 1 is used.
The dash style used for the outline of the TextBox. If not defined, Solid is used.
Adds a TextBox to a Document.
Syntax
'Declaration
 
Public Function AddTextBox( _

   ByVal width As Single, _

   ByVal height As Single, _

   Optional ByVal text As String, _

   Optional ByVal formatting As Formatting, _

   Optional ByVal fillColor As Nullable(Of Color), _

   Optional ByVal outlineColor As Nullable(Of Color), _

   Optional ByVal outlineWidth As Single, _

   Optional ByVal outlineDash As Nullable(Of DashStyle) _

) As Shape
'Usage
 
Dim instance As Document

Dim width As Single

Dim height As Single

Dim text As String

Dim formatting As Formatting

Dim fillColor As Nullable(Of Color)

Dim outlineColor As Nullable(Of Color)

Dim outlineWidth As Single

Dim outlineDash As Nullable(Of DashStyle)

Dim value As Shape

 

value = instance.AddTextBox(width, height, text, formatting, fillColor, outlineColor, outlineWidth, outlineDash)

Parameters

width
The width of the TextBox (in points).
height
The height of the TextBox (in points).
text
The text to use in the TextBox. If not defined, an empty paragraph is used.
formatting
The Formatting to use for the text in the TextBox.
fillColor
The Color used to fill the TextBox. If not defined, white is used.
outlineColor
The Color used for the outline of the TextBox. If not defined, black is used.
outlineWidth
The width used for the outline of the TextBox (in points). If not defined, 1 is used.
outlineDash
The dash style used for the outline of the TextBox. If not defined, Solid is used.

Return Value

The newly created TextBox.
Remarks
A TextBox is a Shape with text in it.
Example
// Create a document.

using (var document = DocX.Create("Test.docx"))

{

    // Create a TextBox with text formatting.

    var textBox = document.AddTextBox( 100, 100, "My TextBox", new Formatting() { FontColor = Color.Green } );

    textBox.TextVerticalAlignment = VerticalAlignment.Bottom;

    textBox.TextMarginBottom = 5d;

    textBox.TextMarginTop = 5d;

    textBox.TextMarginLeft = 5d;

    textBox.TextMarginRight = 5d;



    // Create a paragraph and insert the textBox at its 16th character.

    var p = document.InsertParagraph( "Here is a simple TextBox positioned on the 16th character of this paragraph." );

    p.InsertShape( textBox, 16 );



    // Save all changes made to this document.

    document.Save();

}
Requirements

Target Platforms: Windows 11, Windows 10, Windows 7, Windows, 11, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

Document Class
Document Members