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

# TCustomGrid.UpdateSelectionRange

Updates the selection range when the current selection in the grid has changed.

## Declaration

Source position: grids.pas line 1209

`protected procedure TCustomGrid.UpdateSelectionRange;`

## Description

UpdateSelectionRange is a method used to update the Selection property with the cell coordinates for the current cell or row in the grid control. UpdateSelectionRange creates a new TRect instance with the cell coordinates representing the current selection in the grid.

UpdateSelectionRange uses values in ColCount, RowCount, and Options to determine whether the rectangle represents an empty selection, a single cell, or all cells in the current Row.

When ColCount and RowCount both contain 0 (zero), the selection range is an empty rectangle (Top, Left, Bottom, and Right members in the rectangle are -1).

When goRowSelect has been included in Options, the rectangle contains the first non-fixed column and last column numbers for the current Row. If row selection is not enabled in Options, the rectangle uses the values in Col and Row to represent both the start and end cells for the selection range.

UpdateSelectionRange is called from the ClearSelections and FixPosition methods.

## See also

TCustomGrid.Col |  | Column index for the selected grid cell.
TCustomGrid.ColCount |  | Number of columns in the grid.
TCustomGrid.FixedCols |  | The number of fixed columns in the grid.
TCustomGrid.Options |  | Contains the set of optional features and/or behaviors enabled for the grid control.
TCustomGrid.Row |  | Row number for the selected grid cell.
TCustomGrid.RowCount |  | Number of rows in the grid.