vcl-dxspreadsheetcore-dot-tdxspreadsheethistory-dot-beginaction-x28-dxspreadsheetcore-dot-tdxspreadsheethistoryactionclass-x29.md
Locks the action history and starts to record a series of document changes as a single history action.
procedure BeginAction(AActionClass: TdxSpreadSheetHistoryActionClass);
| Name | Type |
|---|---|
| AActionClass | TdxSpreadSheetHistoryActionClass |
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;
TdxSpreadSheetTableView *ATableView;
TdxSpreadSheetCell *ACell;
ATableView = dxSpreadSheet1->ActiveSheetAsTable;
Randomize();
dxSpreadSheet1->History->BeginAction(__classid(TdxSpreadSheetHistoryEditCellAction);
ATableView->BeginUpdate();
for(int I = 0; I < 10; I++)
for(int J = 0; J < 10; J++)
{
ACell = ATableView->CreateCell(I, J);
ACell->AsInteger = Random(1000);
}
ATableView->EndUpdate();
dxSpreadSheet1->History->EndAction();
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