TX Text Control .NET for Windows Forms

GetItem Method

Method|Introduced in 14.0
Namespace
TXTextControl
Package
TXTextControl.TextControl.WinForms.SDK as TXTextControl.dll from the private NuGet feed or Text Control Offline Packages

Description

Gets a particular field of the type ApplicationField from the collection.

Syntax

GetItem()

Gets the field at the current input position or null, if there is no such field at the current input position.

public ApplicationField GetItem();

GetItem(int)

Gets the field with the specified id, previously set with the ID property.

public ApplicationField GetItem(int id);
ParameterDescription
id

Specifies the field's identifier set with the ID property. The method returns null, if a field of the type ApplicationField with the specified identifier does not exist.

Examples

The following example retrieves a merge field by its stable ID and updates its displayed text.

textControl.Text = "Dear ,";
textControl.InputPosition = new InputPosition(5);
ApplicationFieldCollection fields = textControl.ApplicationFields;
ApplicationField customerField = new(ApplicationFieldFormat.MSWord, "MERGEFIELD", "Customer name", new[] { "CustomerName" }) { ID = 100 };
fields.Add(customerField);
ApplicationField field = fields.GetItem(100);
if (field != null)
{
    field.Text = "Contoso Ltd.";
}