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

# TCustomGrid.CheckPosition

Determines if the cell can be selected, or finds a suitable position using auto-advance.

## Declaration

Source position: grids.pas line 1339

`public procedure TCustomGrid.CheckPosition;`

## Description

CheckPosition is a method used to determine if the cell in Col and Row can be selected. The SelectCell method is called using values in Col and Row as arguments. If the select is selected, no additional actions are performed in the method.

If the cell cannot be selected because the position is invalid, another cell is sought. The AutoAdvance feature is used to check adjacent cells - first, by moving toward the right then downward, and finally by moving to left then upward. GetDeltaMoveNext and MoveNextSelectable are used to find and select a valid cell position.

In some cases, AutoAdvance and the current cell cannot be used to find an available cell. For this case, a scan of all non-fixed columns an rows is performed until a suitable column and row number are found, and MoveNextSelectable is called. If this too fails, the cell position cannot be determined.

CheckPosition is called from CreateWnd when the window handle is created (or re-created) for the control. It is also called when a new value is assigned to the ColCount or RowCount properties.