GetEnumerator Method
- Namespace
TXTextControl
- Package
TXTextControl.asTextControl. Core. SDK TXTextControl.from the private NuGet feed or Text Control Offline PackagesCore. dll
- Also in
TXTextControl.asTextControl. ASP. SDK TXTextControl.dll
Description
Returns an enumerator that can be used to iterate through the collection.
Syntax
public SubTextPartCollection.SubTextPartEnumerator GetEnumerator();Public Function GetEnumerator() As SubTextPartCollection.SubTextPartEnumeratorReturn 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;
}
}textControl.Text = "Customer: Contoso Ltd."
textControl.Select(10, 12)
Dim parts As SubTextPartCollection = textControl.SubTextParts
Dim customer As New SubTextPart("CustomerName", 10) With { .Data = "{""category"":""customer""}" }
parts.Add(customer)
Dim enumerator As IEnumerator = parts.GetEnumerator()
While enumerator.MoveNext()
Dim part As SubTextPart = DirectCast(enumerator.Current, SubTextPart)
If part.Name = "CustomerName" Then
part.HighlightMode = HighlightMode.Always
End If
End While