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

# TLVCompare

Specifies a routine used to compare the values in two items in a list view control.

## Declaration

Source position: comctrls.pp line 1311

`type TLVCompare = function(`
`Item1: TListItem;`
`Item2: TListItem;`
`AOptionalParam: PtrInt`
`):Integer;`

## Arguments

`Item1` |  | First list item for the comparison.
`Item2` |  | Second list item for the comparison.
`AOptionalParam` |  | Pointer to an optional Integer value used in the comparison.

## Function result

Relative sort order for the specified list items.

## Description

TLVCompare is a routine used to determine the relative sort order for the list items passed in the Item1 and Item2, and allows an optional Integer parameter value used in the comparison. The return value is the relative sort order for the TListItem instances. For example:

-1
  Item1 comes before Item2 in the sort order.
0
  Item1 and Item2 have the same sort order value.
1
  Item1 comes after Item2 in the sort order.

A TLVCompare type is passed as an argument to the CustomSort method in TCustomListView.

## See also

TCustomListView.CustomSort |  | Sorts the Items for the list view control using the specified procedure or the OnCompare event handler.
TListItem |  | Represents the items created in TCustomListView and descendants.
TLVCompareEvent |  | Specifies an event handler signalled to compare two items in a List View control.