Export (0) Print
Expand All

RichTextBox.Find Method (Char[], Int32, Int32)

Searches a range of text in a RichTextBox control for the first instance of a character from a list of characters.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public int Find(
	char[] characterSet,
	int start,
	int end
)

Parameters

characterSet
Type: System.Char[]

The array of characters to search for.

start
Type: System.Int32

The location within the control's text at which to begin searching.

end
Type: System.Int32

The location within the control's text at which to end searching.

Return Value

Type: System.Int32
The location within the control where the search characters are found.

ExceptionCondition
ArgumentNullException

characterSet is null.

ArgumentException

start is less than 0 or greater than the length of the text in the control.

This version of the Find method searches for the first instance of a character from a list of characters specified in the characterSet parameter and returns the location of the character. For example, you pass an array of characters containing the character 'Q'. If the control contained the text "The Quick Brown Fox", the Find method would return the value of four. An upper case character and a lower case character are considered different values in the search.

If the property returns a negative value, the characters being searched for were not found within the contents of the control. You can use this method to search for a group of characters within the control. If a character from the character list provided in the method's characterSet parameter is found, the value returned by this method is a zero based index of the character's position in the control. A space is considered a character by the method when determining the location of a character.

This version of the Find method enables you to search for a character set from a range of text in the control by specifying a value for the start and end parameters. A value of zero for the start parameter indicates that the search should start from the beginning of the control's document. A -1 value for the end parameter indicates that the search should end at the end of the text within the control. You can use this version of the Find method to narrow your search to a specific range of text within the control to avoid searching areas of the document that are not important to the needs of your application.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft