TX Text Control .NET Server

Find Method

Method|Introduced in 16.0
Namespace
TXTextControl
Package
TXTextControl.TextControl.Core.SDK as TXTextControl.Core.dll from the private NuGet feed or Text Control Offline Packages
Also in
TXTextControl.TextControl.ASP.SDK as TXTextControl.dll

Description

Finds a text string in the text part.

Syntax

int Find(string text, int start, FindOptions options);

Parameters

ParameterDescription
text

Specifies the text to search for.

start

Specifies the text position where the search starts, beginning with 0. If this value is -1, the search begins at the current text input position.

options

Specifies search options. It can be a combination of the FindOptions values.

Return Value

If the text searched for is found, the method returns the index (zero-based) of the first character of the search string. If the specified text is not found the method returns -1.

Examples

The following example applies bold formatting through the iformatted text's selection by using IFormattedText.Find.

Selection formattedSelection = iFormattedText.Selection;
formattedSelection.Bold = true;
iFormattedText.Selection = formattedSelection;

int position = iFormattedText.Find("Quarterly results", 1, FindOptions.Reverse);
if (position >= 0)
{
    Console.WriteLine($"Found at position {position}.");
}