TdxSpreadSheetHistory.BeginAction(TdxSpreadSheetHistoryActionClass) Method
Locks the action history and starts to record a series of document changes as a single history action.
Declaration
procedure BeginAction(AActionClass: TdxSpreadSheetHistoryActionClass);
Parameters
Name | Type |
---|---|
AActionClass | TdxSpreadSheetHistoryActionClass |
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. Pass a reference to the required history action class as the AActionClass parameter.
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.