ListView.FindItemWithText Method (String, Boolean, Int32, Boolean) (System.Windows.Forms)

Switch View :
ScriptFree
.NET Framework Class Library
ListView.FindItemWithText Method (String, Boolean, Int32, Boolean)

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)
Syntax

Visual Basic
Public Function FindItemWithText ( _
	text As String, _
	includeSubItemsInSearch As Boolean, _
	startIndex As Integer, _
	isPrefixSearch As Boolean _
) As ListViewItem
C#
public ListViewItem FindItemWithText(
	string text,
	bool includeSubItemsInSearch,
	int startIndex,
	bool isPrefixSearch
)
Visual C++
public:
ListViewItem^ FindItemWithText(
	String^ text, 
	bool includeSubItemsInSearch, 
	int startIndex, 
	bool isPrefixSearch
)
F#
member FindItemWithText : 
        text:string * 
        includeSubItemsInSearch:bool * 
        startIndex:int * 
        isPrefixSearch:bool -> ListViewItem 

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.
isPrefixSearch
Type: System.Boolean
true to allow partial matches; otherwise, false.

Return Value

Type: System.Windows.Forms.ListViewItem
The first ListViewItem that begins with the specified text value.
Exceptions

Exception Condition
ArgumentOutOfRangeException

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

Remarks

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

The search is case-insensitive.

The text parameter can specify a substring of the desired matching text. This method will return the first item that starts with the specified text, unless false is passed in for isPrefixSearch. 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 search text will return the item whose text is "bracket". If isPrefixSearch is set to false, this call will return null.

Version Information

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Platforms

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
See Also

Reference