TX Text Control .NET Server

TextFieldCollection Object

Object|Introduced in 28.0

Description

Contains all standard text fields in a Text Control document or part of the document.

Syntax

TextFieldCollection

Examples

The following example demonstrates TextFieldCollection in a practical document-editing workflow. It contains all standard text fields in a Text Control document or part of the document.

function onTxError(error) {
    console.error("TX Text Control error:", error.msg);
    error.handled = true;
}

TXTextControl.textParts.getMainText(function(mainText) {
    const textFields = mainText.textFields;
    textFields.getItem(
        function(field) {
            if (!field) {
                console.warn("No text field was returned.");
                return;
            }
            
            console.log("get item result:", field);
        },
        onTxError,
        25
    );
}, onTxError);

Members

Methods

MethodDescription
addAdds a new TextField to the collection.
addWithTextAdds a new TextField with the given text to the collection.
clearRemoves all text fields from a Text Control document.
elementAtReturns the element at a specified index in the collection. (Inherited from Collection.)
forEachExecutes a callback function for each element. (Inherited from Collection.)
getCountGets the number of elements contained in the collection. (Inherited from Collection.)
getItemGets the text field at the current text input position or the text field with the specified id.
removeRemoves the text field from the Text Control document.

Further Reading

  • Removing TextFields in a Loop –