TX Text Control .NET for Windows Forms Documentation

TextFrame.Find Method

Finds a text string in a text frame.

Introduced: 13.0.

Syntax

[C#] 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
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. A combination of the following values are possible:


ValueMeaning
NoHighlightThe search text, if found, is not highlighted.
NoMessageBoxDoes not display message boxes to inform about search results.
MatchCaseLocates only instances of the search text that have the exact casing.
ReverseThe search starts at the end of the control's document and searches to the beginning of the document.

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.

Example

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

[C#] 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 Next

See Also

 
 
 

Products

Support

Downloads

Corporate

Buy Now