[Overview][Constants][Types][Classes][Procedures and functions][Index] | Reference for unit 'ComCtrls' (#lcl)

# TListItems.FindData

Locates the list item which has the specified values in its Data property.

## Declaration

Source position: comctrls.pp line 1178

`public function TListItems.FindData(`
`const AData: Pointer`
`):TListItem; overload; function TListItems.FindData(`
`StartIndex: Integer;`
`Value: Pointer;`
`Inclusive: Boolean;`
`Wrap: Boolean`
`):TListItem; overload;`

## Arguments

`AData` |  | Pointer with the values to locate in the Data property for the list items.

## Function result

TListItem instance with the specified data, or Nil when not found.

## Arguments

`StartIndex` |  | Ordinal position in the container where the search is started.
`Value` |  | Pointer with the values to locate in the Data for the list items.
`Inclusive` |  | True if the list item at StartIndex is included in the search. False if the search starts at the next position in the container.
`Wrap` |  | True if the search can wrap to the start of the container if a match is not found prior to the end of the container.

## Description

FindData is an overloaded method used to find the first TListItem instance with a Data property that matches the specified value.

The overloaded variants allow either a pointer to the value to locate in Data, or use of a starting position and wrapping in the search criteria.

The variant with a Pointer argument checks the cached list item for a matching value. When found, no other actions are performed in the method.

Otherwise, each of the TListItem instances in Item is visited to compare the pointer value to the Data property in the list item. When a match is found, the list item becomes the active cache entry for the container.

The variant with search criteria works differently. It does not check the active cache entry before starting its search. Use StartIndex to specify the initial list item in the container checked as a match for the pointer in Value. Use Inclusive to specify whether StartIndex is included in the search, or the next list item is used. Set Wrap to True to allow the search to continue at the first item in the container when a match is not found. In this variant, the active cache entry is not updated when a match is found.

The return value is Nil if a list item is not found (in the cache or in Item) containing the specified value.

Use FindCaption to locate a list item with a specified value in its Caption.

## See also

TListItems.FindCaption |  | Locates a list item with the specified caption starting at given position in the container.
TListItem.Data |  | Pointer to arbitrary Data associated with the list item.