TX Text Control .NET for WPF

GetEnumerator Method

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

Description

Returns an enumerator that can be used to iterate through the collection.

Syntax

public SubTextPartCollection.SubTextPartEnumerator GetEnumerator();

Return Value

The return value is an IEnumerator that represents the collection.

Examples

The following example explicitly enumerates named regions and highlights customer data.

textControl.Text = "Customer: Contoso Ltd.";
textControl.Select(10, 12);
SubTextPartCollection parts = textControl.SubTextParts;
SubTextPart customer = new("CustomerName", 10) { Data = @"{""category"":""customer""}" };
parts.Add(customer);
IEnumerator enumerator = parts.GetEnumerator();
while (enumerator.MoveNext())
{
    SubTextPart part = (SubTextPart)enumerator.Current;
    if (part.Name == "CustomerName")
    {
        part.HighlightMode = HighlightMode.Always;
    }
}