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

# TCustomListBox.ItemAtPos

Get the item index for the given client coordinates.

## Declaration

Source position: stdctrls.pp line 621

`public function TCustomListBox.ItemAtPos(`
`const Pos: TPoint;`
`Existing: Boolean`
`):Integer;`

## Arguments

`Pos` |  | The item position.
`Existing` |  | True when the index is requested for insertion of a new item.

## Function result

The calculated item index, can be out of the Items bounds.

## Description

ItemAtPos is an Integer function used to get the index position in Items for the value at the specified screen coordinates.

Pos is TPoint instance with the X and Y coordinates used in the method.

Existing indicates whether the return value is set to -1 or the number of entries in Items when Pos refers to entry which does not exist. When Existing is set to True, -1 is returned for an invalid entry. Otherwise, the value in Item.Count is returned.

ItemAtPos calls GetIndexAtXY using the X and Y values in Pos to locate the index for the item.

## See also

TCustomListBox.GetIndexAtXY |  | Gets the index for the item at the given client coordinates.