TcxCustomDataController.SelectRows(Integer,Integer) Method
Selects a range of rows.
Declaration
procedure SelectRows(AStartRowIndex: Integer; AEndRowIndex: Integer);
Parameters
Name | Type | Description |
---|---|---|
AStartRowIndex | Integer | The index of the first selected row in the target range. |
AEndRowIndex | Integer | The index of the last selected row in the target range. |
Remarks
Call the SelectRows
procedure to select a range of visible data and grouping rows if the MultiSelect property is set to True
. If AStartRowIndex
and AEndRowIndex
parameter values are equal, the SelectRows
procedure selects only one row. You can use the RowCount property to identify the number of rows available for selection.
To select all rows, call the SelectAll procedure. If you need to select or deselect individual rows, call the ChangeRowSelection procedure.
Code Example
The following code example selects a data row if it contains a specific value in the target unbound grid column:
uses
cxVariants; // This unit declares the VarEquals function
// ...
procedure TMyForm.SelectRecord(AColumn: TcxGridColumn; const AValue: Variant);
var
I, AIndex: Integer;
begin
if AColumn = nil then Exit;
AColumn.GridView.BeginUpdate; // Initiates the following batch change
try
for I := 0 to AColumn.GridView.DataController.RecordCount - 1 do
if VarEquals(AColumn.GridView.DataController.Values[I, AColumn.Index], AValue) then
begin
AIndex := AColumn.GridView.DataController.GetRowIndexByRecordIndex(I, False);
if AIndex > -1 then
AColumn.GridView.DataController.SelectRows(AIndex, AIndex);
end;
finally
AColumn.GridView.EndUpdate; // Calls EndUpdate regardless of the batch operation's success
end;
end;
See Also