Skybound AutoComplete

AutoComplete.FindString Method (String, Int32)

Finds the first item from the given index which starts with the specified string.

[Visual Basic]
Overloads Public Function FindString( _
   ByVal text As String, _
   ByVal startIndex As Integer _
) As Integer
[C#]
public int FindString(
   string text,
   int startIndex
);

Parameters

text
A String to search for.
startIndex
The 0-based index of the item before the first item to be searched. Set to -1 to search from the beginning of the list.

Return Value

The 0-based index of the first item found; returns -1 if no match is found.

Remarks

The search performed by this method is not case-sensitive. The text parameter is a substring to compare against the text associated with the items in the AutoComplete. The search performs a partial match starting from the beginning of the text, returning the first item in the list that matches the specified substring. You can then perform tasks, such as removing the item that contains the search text using the RemoveAt method. The startIndex overloads are typically used after a call has been made using the overload that does not specify a starting index. Once an initial item has been found in the list, it is typically used to find further instances of the search text by specifying the index position in the startIndex parameter of the item after the first found instance of the search text.

If you want to perform a search for an exact word match instead of a partial match, use the overload with the exact parameter.

Exceptions

Exception Type Condition
ArgumentOutOfRangeException

The startIndex is less than -1.

-or-

The startIndex is greater than the last index in the collection.

See Also

AutoComplete Class | Skybound.AutoComplete Namespace | AutoComplete.FindString Overload List