Skip to main content

TdxSpreadSheetHistory.EndAction(Boolean) Method

Adds a recorded series of document changes to the undo list as a single action and unlocks the action history.

Declaration

procedure EndAction(ACanceled: Boolean = False);

Parameters

Name Type
ACanceled Boolean

Remarks

A spreadsheet control records every change to the opened document into the undo action list if the history functionality is enabled. If you make a large series of changes programmatically, the resulting action list can occupy much memory. Enclose your code between BeginAction and EndAction procedure calls to record all the changes it makes as a single history action.

An EndAction procedure call finishes a series of document changes as a single history action and adds it to the UndoActions list. You can pass True as the ACanceled parameter to discard the recorded action, which is useful if an error occurs during any of the recorded operations.

For instance, the following code populates range 10 by 10 cells with random integers from 0 to 1000 and records these changes as a single cell edit action. You can undo these changes in a single step rather than in 100 steps.

var
  ATableView: TdxSpreadSheetTableView;
  ACell: TdxSpreadSheetCell;
  I, J: Integer;
begin
  ATableView := dxSpreadSheet1.ActiveSheetAsTable;
  Randomize;
  dxSpreadSheet1.History.BeginAction(TdxSpreadSheetHistoryEditCellAction);
  ATableView.BeginUpdate;
  for I := 0 to 9 do
    for J := 0 to 9 do
    begin
      ACell := ATableView.CreateCell(I, J);
      ACell.AsInteger := Random(1000);
    end;
  ATableView.EndUpdate;
  dxSpreadSheet1.History.EndAction;
end;

Ensure that an EndAction procedure call follows every BeginAction call, even if an exception occurs. Otherwise – the action lists remain locked and cannot record new document changes.

See Also