Click or drag to resize
TextRangeFindText Method (String, RangeMatchType)
Searches to the end of the story for the text given by text. The matching criteria are given by flags.

Namespace: TextObjectModel
Assembly: ManagedTOM2 (in ManagedTOM2.dll) Version: 1.0.5577.41188
Syntax
public int FindText(
	string text,
	[OptionalAttribute] RangeMatchType flags
)

Parameters

text
Type: SystemString
String to find.
flags (Optional)
Type: TextObjectModelRangeMatchType
Flags governing comparisons.

Return Value

Type: Int32
The length of string matched.
Examples
The following example demonstrates how to find text in a range:
C#
void FindTextExample(TextDocument document) {
    TextRange range = document.EntireRange;
    range.Text = "This is my first. This is my second.";

    int result;

    result = range.FindText("my");

    // substring found at position 8
    if (result > 0)
        Console.WriteLine("Substring found at position {0}", range.Start);
    else
        Console.WriteLine("Substring not found");

    range.Expand(TextUnit.Story);
    result = range.FindText("my", 6);

    // substring not found
    if (result > 0)
        Console.WriteLine("Substring found at position {0}", range.Start);
    else
        Console.WriteLine("Substring not found");
}
See Also