ListView.FindItemWithText Method (String, Boolean, Int32)

 

Finds the first ListViewItem or ListViewItem.ListViewSubItem, if indicated, that begins with the specified text value. The search starts at the specified index.

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

public ListViewItem FindItemWithText(
	string text,
	bool includeSubItemsInSearch,
	int startIndex
)

Parameters

text
Type: System.String

The text to search for.

includeSubItemsInSearch
Type: System.Boolean

true to include subitems in the search; otherwise, false.

startIndex
Type: System.Int32

The index of the item at which to start the search.

Return Value

Type: System.Windows.Forms.ListViewItem

The first ListViewItem that begins with the specified text value.

Exception Condition
ArgumentOutOfRangeException

startIndex is less 0 or more than the number items in the ListView.

The search is case-insensitive.

The text parameter can specify a substring of the desired matching text. In addition, this method will return the first item that starts with the specified text. For example, if a ListView contains two list items—the first item's text set to "angle bracket" and the second item's text set to "bracket"—a call to FindItemWithText passing "brack" as the parameter will return the item whose text is "bracket".

The FindItemWithText method returns null if the list is empty or there is no matching item.

.NET Framework
Available since 2.0
Return to top
Show: