Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

ComboBox.FindString Method (String, Int32)

Finds the first item after the given index which starts with the given string. The search is not case sensitive.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

public int FindString (
	string s,
	int startIndex
)
public int FindString (
	String s, 
	int startIndex
)
public function FindString (
	s : String, 
	startIndex : int
) : int
Not applicable.

Parameters

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.

Return Value

The zero-based index of the first item found; returns -1 if no match is found, or 0 if the s parameter specifies Empty.

Exception typeCondition

ArgumentOutOfRangeException

The startIndex is less than -1.

-or-

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

The search performed by this method is not case-sensitive. The s parameter is a substring to compare against the text associated with the items in the combo box list. 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 Remove 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 a search for an exact word match instead of a partial match, use the FindStringExact method.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2015 Microsoft