FindItem

This method finds and returns a reference to a ListItem object in a ListView control.

Syntax

listview.FindItem (string, [value], [index], [match])

Parameters

listview
Required. Object expression that evaluates to a ListView control.
string
Required. String expression that indicates the ListItem object to be found.
value
Optional. Integer or constant that specifies whether the string will be matched to the ListItem object's Text or SubItems property. The following table describes the settings for value.
Constant
Value
Description
lvwText 0 (Default) Matches string with a ListItem object's Text property.
lvwSubitem 1 Matches string with any string in a ListItem object's SubItems property.

index
Optional. An integer or string that uniquely identifies a member of an object collection and specifies the location from which to begin the search. The integer is the value of the Index property and the string is the value of the Key property. If no index is specified, the default is 1.
match
Optional. An integer or constant specifying that a match will occur if the item's Text property is the same as the string. The following table describes the settings for match.
Constant
Value
Description
lvwWholeWord 0 (Default) An integer or constant specifying that a match will occur if the item's Text property begins with the whole word being searched. Ignored if the criteria is not text.
lvwPartial 1 An integer or constant specifying that a match will occur if the item's Text property begins with the string being searched. Ignored if the criteria is not text.

Return Value

Returns the first ListItem that matches all the search criteria.

Remarks

If you specify lvwText as the search criteria, you can set the match to lvwPartial. This setting ensures that a match occurs when the Text property of the ListItem object begins with the string you are searching for.