Finds a text string in a text frame.
Introduced: 13.0.
public int Find(string text, int start, FindOptions options);
Public Function Find(ByVal text As String, ByVal start As Integer, ByVal options As FindOptions) As Integer
Parameter | Description |
---|---|
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 Find |
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 (TXTextControl.TextFrame tf in textControl1.TextFrames)
{
for (position=0;
(position = tf.Find("test", position, TXTextControl.FindOptions.NoHighlight | TXTextControl.FindOptions.NoMessageBox)) != -1;
count++, position++);
}
Dim position As Integer = 0, count As Integer = 0
For Each tf As TXTextControl.TextFrame In textControl1.TextFrames
position = 0
While (position = tf.Find("test", position, TXTextControl.FindOptions.NoHighlight Or TXTextControl.FindOptions.NoMessageBox)) <> -1
count += 1
position += 1
End While
Next