Skip to main content

TdxSpreadSheetTableViewSelection.Add(string,TShiftState,string) Method

Adds the specified cell or cell range to the selected area collection.

Declaration

procedure Add(const AArea: string; AShift: TShiftState; const AFocusedCell: string); overload;

Parameters

Name Type Description
AArea string

A reference to the target cell range in the A1 format.

AShift TShiftState

Indicates the state of the modifier keys, mouse buttons, or touch devices.

AFocusedCell string

A reference to the the target cell in the A1 format.

Remarks

Call this procedure to emulate user actions that change the current cell selection state. The AShift parameter allows you to emulate a user action, such as holding down the Ctrl, Alt, and/or Shift keys. Pass a reference to a cell you want to focus within the selected cell range as the AFocusedCell parameter. An Add procedure call moves focus to the upper-left cell within the selected cell range if you specify 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('B2:D4');
  // Selects the second cell range (B6:D8)
  ATableView.Selection.Add('B6:D8', [ssCtrl]);
  // Selects the last cell range (B10:D13) and moves focus to the C12 cell
  ATableView.Selection.Add('B10:D13', [ssCtrl], 'C12');
  // Resumes selection state updates and applies all the changes
  ATableView.Selection.EndUpdate;
end;

Expand Cell Selection Example

See Also