TXTextControl.TextFrame.Find Method

Finds a text string in a text frame.

Introduced: 13.0.


public int Find(string text, int start, FindOptions options);
[Visual Basic]
Public Function Find(ByVal text As String, ByVal start As Integer, ByVal options As FindOptions) As Integer
Parameter Description

Specifies the text to search for.


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.


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.


The following example counts all occurrences of the specified string in all text frames of a TX Text Control document:

int position = 0, count = 0;

foreach (TextFrame tf in textControl1.TextFrames)
    for (position=0;
    (position = tf.Find("test", position, FindOptions.NoHighlight | FindOptions.NoMessageBox)) != -1;
    count++, position++);
[Visual Basic]
Dim position As Integer = 0, count As Integer = 0

For Each tf As TextFrame In textControl1.TextFrames
    position = 0
    While (position = tf.Find("test", position, FindOptions.NoHighlight Or FindOptions.NoMessageBox)) <> -1
        count += 1
        position += 1
    End While

See Also