- s
- The string to search for.
- startIndex
- The zero-based index of the item before the first item to be searched. Set to -1 to search from the beginning of the control.
The zero-based index of the first item found; returns -1 if no match is found, or 0 if the s parameter specifies string.Empty.
The search performed by this method is not case-sensitive. The s parameter is a string to compare against the text associated with the items in the combo box list. The search looks for a 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 System.Windows.Forms.ComboBox.ObjectCollection.Remove(object) method or changing the item's text. This method is typically used after a call has been made using the version of this method that does not specify a starting index. Once an initial item has been found in the list, this method 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 partial word search instead of an exact word match, use the ComboBox.FindString(string) method.
The search performed by this method is circular. Although the search starts at the next index after the startIndex parameter, the search restarts at 0 when the end of the collection is reached. However, note that if the startIndex parameter itself is equal to the last index in the collection, an exception is thrown.