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

# TCustomGrid.DoOPExchangeColRow

Performs an exchange of values for the columns or rows with the specified indexes.

## Declaration

Source position: grids.pas line 1045

`protected procedure TCustomGrid.DoOPExchangeColRow(`
`IsColumn: Boolean;`
`index: Integer;`
`WithIndex: Integer`
`);`

## Arguments

`IsColumn` |  | True if Index refers to a column instead of a row.
`index` |  | Position for a column or row exchanged in the method.
`WithIndex` |  | Position for the other column or row exchanged in the method.

## Description

DoOPExchangeColRow is used to exchange or swap column or row values at the specified positions in the grid control.

IsColumn indicates whether columns or rows are affected in the method. When set to True, Index and WithIndex refer to column positions. Otherwise, they refer to row positions.

TGridColumn instances in Columns are exchanged when the collection has been enabled in the control. Column widths in Cols, or row heights in Rows are also exchanged in the method.

DoOPExchangeColRow calls the ColRowExchanged method to perform the notification which informs the grid control to exchange their column or row data.

AdjustEditorBounds is called to reposition the cell Editor for the grid when the operation requires it to be moved.

When a value in Index or WithIndex is a sort column for the grid, the value in the SortColumn property is updated to reflect the (ex)changed value.

DoOPExchangeColRow is called from the Sort method when the StrictSort property is set to False.