Export (0) Print
Expand All

ToolStripComboBox.FindString Method (String, Int32)

Finds the first item after the given index which starts with the given string.

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

public int FindString(
	string s,
	int startIndex
)

Parameters

s
Type: System.String

The String to search for.

startIndex
Type: System.Int32

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

Type: System.Int32
The zero-based index of the first item found; returns -1 if no match is found.

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 at the specified index, and returns 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 or changing the item's text. Once you have found the specified text, if you want to search for other instances of the text in the ToolStripComboBox, use this method to specify a starting index within the ToolStripComboBox. If you want to perform a search for an exact word match instead of a partial match, use the FindStringExact method.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft