ActiveReports 6 Online Help
Find(String,Int32,FindOptions) Method
Example 

The text to locate in the control.
The location within the control's text at which to begin searching.
A bitwise combination of the FindOptions values.
Searches the text in the RichTextBox control for a specified string starting at a specified location and with specific options applied to the search.
Syntax
'Declaration
 
Public Overloads Function Find( _
   ByVal str As String, _
   ByVal start As Integer, _
   ByVal findOptions As RichTextBox.FindOptions _
) As Integer
public int Find( 
   string str,
   int start,
   RichTextBox.FindOptions findOptions
)

Parameters

str
The text to locate in the control.
start
The location within the control's text at which to begin searching.
findOptions
A bitwise combination of the FindOptions values.

Return Value

The location within the control where the search text was found.
Remarks

The Find method searches for the text specified in the str parameter and returns the location of the first character within the control. If the property returns a negative value, the text string being searched for was not found within the contents of the control.

With this version of the Find method, you can specify options that enable you to expand or narrow your search. You can specify options that enable you to match the casing of the search word or to search for entire words instead of partial words. By specifying the FindOptions.Reverse enumeration in the options parameter, you can search for text from the bottom of the document to the top instead of the default top to bottom search method. This version of the Find method also enables you to narrow the search for text by selecting a specific starting position within the control's text. This feature can enable you to avoid text that might have already been searched or where the specific text you are searching for is known not to exist. When the FindOptions.Reverse value is specified in the options parameter, the value of the start parameter indicates the position where the reverse search will end since the search will start at the bottom of the document when using this version of the Find method.

Note   The Find methods that accept a string as a parameter cannot find text that is contained on more than one line of text within the RichTextBox.  Performing such a search will return a value of negative one (-1).
Example
private void Detail_Format(object sender, System.EventArgs eArgs)
{
    if (this.RichTextBox1.Find("expires", 1, RichTextBox.FindOptions.None)!= -1)
    {
        this.RichTextBox1.SelectionStart = this.RichTextBox1.Find("expires", 1, RichTextBox.FindOptions.None);
        this.RichTextBox1.SelectionLength = 7;
        this.RichTextBox1.SelectionColor = System.Drawing.Color.Crimson;
    }
}
Private Sub Detail_Format(ByVal sender As Object, ByVal e As System.EventArgs) Handles Detail.Format
    If Not Me.RichTextBox1.Find("expires", 1, RichTextBox.FindOptions.None) = -1 Then
        Me.RichTextBox1.SelectionStart = Me.RichTextBox1.Find("expires", 1, RichTextBox.FindOptions.None)
        Me.RichTextBox1.SelectionLength = 7
        Me.RichTextBox1.SelectionColor = System.Drawing.Color.Crimson
    End If
End Sub
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

RichTextBox Class
RichTextBox Members
Overload List

Send Feedback