Class WTextFormField
Represents the text form field in the Word document.
Inheritance
Inherited Members
Namespace: Syncfusion.DocIO.DLS
Assembly: Syncfusion.DocIO.Portable.dll
Syntax
public class WTextFormField : WFormField, IXDLSSerializable, IOfficeRun, IStringWidget, ISplitLeafWidget, ITextMeasurable, IWField, IWTextRange, IParagraphItem, IEntity, ILeafWidget, IWidget
Examples
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
WParagraph paragraph = section.AddParagraph() as WParagraph;
paragraph.AppendText("General Information");
section.AddParagraph();
paragraph = section.AddParagraph() as WParagraph;
IWTextRange text = paragraph.AppendText("Name\t");
text.CharacterFormat.Bold = true;
//Append Text form field
WTextFormField textfield = paragraph.AppendTextFormField(null);
//Set type of Text form field
textfield.Type = TextFormFieldType.RegularText;
textfield.CharacterFormat.FontName = "Calibri";
textfield.CalculateOnExit = true;
section.AddParagraph();
paragraph = section.AddParagraph() as WParagraph;
text = paragraph.AppendText("Date of Birth\t");
text.CharacterFormat.Bold = true;
//Append Text form field
textfield = paragraph.AppendTextFormField("Date field", DateTime.Now.ToString("MM/DD/YY"));
textfield.StringFormat = "MM/DD/YY";
//Set Text form field type
textfield.Type = TextFormFieldType.DateText;
textfield.CalculateOnExit = true;
//Save the Word document
document.Save("Textfield.docx", FormatType.Docx);
//Close the document
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 WParagraph = TryCast(section.AddParagraph(), WParagraph)
paragraph.AppendText("General Information")
section.AddParagraph()
paragraph = TryCast(section.AddParagraph(), WParagraph)
Dim text As IWTextRange = paragraph.AppendText("Name" & vbTab)
text.CharacterFormat.Bold = True
'Append Text form field
Dim textfield As WTextFormField = paragraph.AppendTextFormField(Nothing)
'Set type of Text form field
textfield.Type = TextFormFieldType.RegularText
textfield.CharacterFormat.FontName = "Calibri"
textfield.CalculateOnExit = True
section.AddParagraph()
paragraph = TryCast(section.AddParagraph(), WParagraph)
text = paragraph.AppendText("Date of Birth" & vbTab)
text.CharacterFormat.Bold = True
'Append Text form field
textfield = paragraph.AppendTextFormField("Date field", DateTime.Now.ToString("MM/DD/YY"))
textfield.StringFormat = "MM/DD/YY"
'Set Text form field type
textfield.Type = TextFormFieldType.DateText
textfield.CalculateOnExit = True
'Save the Word document
document.Save("Textfield.docx", FormatType.Docx)
'Close the document
document.Close()
End Sub
Constructors
WTextFormField(IWordDocument)
Initializes a new instance of the WTextFormField class.
Declaration
public WTextFormField(IWordDocument doc)
Parameters
Type | Name | Description |
---|---|---|
IWordDocument | doc |
Properties
DefaultText
Gets or sets the default text for text form field.
Declaration
public string DefaultText { get; set; }
Property Value
Type | Description |
---|---|
System.String | The string that specifies the default text. |
EntityType
Gets the type of the entity. Read-only.
Declaration
public override EntityType EntityType { get; }
Property Value
Type | Description |
---|---|
EntityType | The EntityType of the current item. |
Overrides
MaximumLength
Gets or sets the maximum text length of the text form field.
Declaration
public int MaximumLength { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The integer that specifies the maximum length of the text. |
StringFormat
Gets or sets the string text format (text, date/time, number) directly.
Declaration
public string StringFormat { get; set; }
Property Value
Type | Description |
---|---|
System.String | The string that specifies the text format. |
Text
Gets or sets the text of text form field.
Declaration
public override string Text { get; set; }
Property Value
Type | Description |
---|---|
System.String | The string that specifies the text. |
Overrides
TextRange
Gets or sets the form field text range.
Declaration
public WTextRange TextRange { get; set; }
Property Value
Type | Description |
---|---|
WTextRange | The WTextRange instance that specifies the form field text. |
Type
Gets or sets text form field type.
Declaration
public TextFormFieldType Type { get; set; }
Property Value
Type | Description |
---|---|
TextFormFieldType | The TextFormFieldType member that specifies the type of text form field. |
Methods
CloneImpl()
Creates a duplicate copy of the entity.
Declaration
protected override object CloneImpl()
Returns
Type | Description |
---|---|
System.Object | The reference to the newly created object. |
Overrides
InitXDLSHolder()
Registers child objects in XDSL holder.
Declaration
protected override void InitXDLSHolder()
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. |