TdxSpreadSheetTableViewSelection.Add(TRect,TShiftState,Integer,Integer) Method
Adds a specified cell or cell range to the selected area collection.
Declaration
procedure Add(AArea: TRect; AShift: TShiftState = []; AFocusedRow: Integer = -1; AFocusedColumn: Integer = -1); overload;
Parameters
Name | Type | Description |
---|---|---|
AArea | TRect | A rectangle that corresponds to the target cell or cell range. |
AShift | TShiftState | Indicates the state of the modifier keys, mouse buttons, or touch devices. |
AFocusedRow | Integer | An index of the row that intersects the focused cell within the last selected cell range. |
AFocusedColumn | Integer | An index of the column that intersects the focused cell within the last selected cell range. |
Remarks
Call this procedure to emulate user actions that change the current cell selection state. The optional AShift parameter allows you to emulate a user action, such as holding down the Ctrl, Alt, and/or Shift keys. Pass row and column indexes of a cell you want to focus within the selected cell range as the AFocusedRow and AFocusedColumn optional parameters, respectively. An Add procedure call moves focus to the upper-left cell within the selected cell range if you omit these parameters or specified a cell outside the selected range.
The following code example uses the AShift parameter to select three non-adjacent cell ranges:
var
ATableView: TdxSpreadSheetTableView;
begin
ATableView := dxSpreadSheet1.ActiveSheetAsTable;
// Stops selection state updates
ATableView.Selection.BeginUpdate;
// Selects the first cell range (B2:D4)
ATableView.Selection.Add(Rect(1, 1, 3, 3));
// Selects the second cell range (B6:D8)
ATableView.Selection.Add(Rect(1, 5, 3, 7), [ssCtrl]);
// Selects the last cell range (B10:D13) and moves focus to the C12 cell
ATableView.Selection.Add(Rect(1, 9, 3, 12), [ssCtrl], 11, 2);
// Resumes selection state updates and applies all the changes
ATableView.Selection.EndUpdate;
end;