Skip to main content

TcxCustomDataController.GetRowIndexByRecordIndex(Integer,Boolean) Method

Returns the position of a data record in a data controller by its record index.

Declaration

function GetRowIndexByRecordIndex(ARecordIndex: Integer; AMakeVisible: Boolean): Integer;

Parameters

Name Type
ARecordIndex Integer
AMakeVisible Boolean

Returns

Type
Integer

Remarks

Use the GetRowIndexByRecordIndex function to return the row index for a specific data record. The function returns a value between 0 and RowCount - 1.

The data record is identified by the ARecordIndex parameter, which specifies the record index. Record indexes vary from 0 to RecordCount - 1.

Record indexes define the order in which data records appear in the underlying data source. Row indexes define the order in which rows (data records and grouping rows) should be displayed on screen. This order depends on the grouping, filtering and/or sorting applied. For more details on record and row indexes, refer to the TcxCustomDataController description.

Row indexes are assigned only to potentially visible rows (i.e. visible now or available by scrolling). Rows collapsed within data groups have no row indexes. If a particular data record is hidden within a collapsed group, you can make it visible by setting the AMakeVisible parameter to True. In this case, GetRowIndexByRecordIndex expands the data group, which contains the record, reassigns row indexes to all potentially visible rows and then returns the row index for the required record.

If the record is hidden within a group and the AMakeVisible parameter is set to False, the function returns -1. The function also returns -1 if the specified record does not match the current filter criteria and therefore cannot be displayed.

If a record is already visible, GetRowIndexByRecordIndex just returns its row index. In this case, AMakeVisible is ignored.

GetRowIndexByRecordIndex does not affect focus. See the FocusedRecordIndex and FocusedRowIndex properties to move focus to a specific record/row.

The row index can be used to:

Iterating though data records is performed differently in provider/unbound and bound modes. In provider & unbound modes, you can use record indexes to access values of a specific record by the Values property.

In bound mode, you have to use methods provided by a TDataSet descendant associated with the data controller to navigate and change records.

See Also