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

# TCustomGrid.TryMoveSelection

Tries to move the cell selection by or to the specified column and row values.

## Declaration

Source position: grids.pas line 1203

`protected function TCustomGrid.TryMoveSelection(`
`Relative: Boolean;`
`var DCol: Integer;`
`var DRow: Integer`
`):Boolean;`

## Arguments

`Relative` |  | True the column and row numbers are relative offsets from the current cell.
`DCol` |  | Column offset or number for the selection.
`DRow` |  | Row offset or number for the selection.

## Function result

True on success.

## Description

TryMoveSelection is a Boolean function used to select the cell represented in the DCol and DRow arguments. These values can be either an absolute cell address or relative offsets from the current cell in Col and Row.

When Relative is True, the arguments can contain positive or negative values. Positive values move the selection to the right (for DCol) or towards the bottom of the grid (for DRow) starting at the cell in Col and Row. Negative values cause the selection to move in the opposite directions for each argument.

When Relative is False,the arguments in DCol and DRow are absolute cell coordinates and should contain only positive values.

TryMoveSelection calls SelectCell to select the cell at the specified column and row.

The return value is True if the specified cell was selected in the method. It is False if DCol or DRow do not represent a valid cell in the grid control. No actions are performed in the method when FixedGrid returns True, and the return value is set to False.

TryMoveSelection is called from the MoveExtend method and occurs before the OnBeforeSelection, OnSelection, and OnAfterSelection event handlers are signalled.