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

# TCustomImageList.CheckIndex

Ensures that an Index position is valid for the bounds of the image list.

## Declaration

Source position: imglist.pp line 312

`protected procedure TCustomImageList.CheckIndex(`
`AIndex: Integer;`
`AForInsert: Boolean = False`
`);`

## Arguments

`AIndex` |  | Index position validated in the method.
`AForInsert` |  | True when the index position is used for insertion (default is False).

## Description

CheckIndex is a procedure used to ensure that the value in AValue is a valid index position for the operations in the class.

AForInsert indicates if AValue is constrained to the existing range of ordinal positions in the list. When AForInsert contains True, AValue must be less than the Count property. When AForInsert is False, the index value is for an append operation and can contain a value less than or equal to the Count property.

An EInvalidOperation exception is raised when AValue is not in the required range for the specified operation.

CheckIndex is used in the implementation of various methods in the class.

## Errors

Raises an EInvalidOperation exception when the index is out of bounds. Raised with the message in SInvalidIndex.