Skip to main content

History

  • 3 minutes to read

The Spreadsheet and Report Designer controls provide the action history functionality. If it is enabled, the control saves all actions performed either by an end-user or programmatically within the currently opened spreadsheet document. End-users can press the Ctrl+Z key combination to consecutively undo their actions. Until a new action is executed in the control, end-users can consecutively restore all previously undone actions by pressing the Ctrl+Y key combination. As an additional option, you can link custom UI elements within your application to the Undo and Redo commands, implemented as the TdxSpreadSheetUndo and TdxSpreadSheetRedo action objects. In addition to the end-user functionality, the controls provide a comprehensive API.

To access and manage the action history, use the control’s History property set. Every time an action is performed within the currently opened spreadsheet document, it is recorded in the history’s UndoActions property. When either the Undo procedure is invoked or an end-user pressed the Ctrl+Z key combination, the last action in the UndoActions list is moved to the RedoActions list, canceling the respective operation’s effect as a result. Then, the action can be restored either by calling the Redo procedure or by pressing the Ctrl+Y key combination. By specifying the optional parameters during the Undo/Redo procedure calls, you can undo/redo the required number of consecutive actions at once. If there are no actions within the UndoActions/RedoActions lists, the Undo/Redo procedures and the respective key combinations have no effect. To track the number of actions in these lists, use the UndoActionCount and RedoActionCount properties.

Every time a new action is added to the UndoActions list, RedoActions is cleared. To protect the actions currently stored within the UndoActions/RedoActions lists, call the Lock procedure. As a result, no new actions can be recorded in the history but you can freely move any number of actions between the lists. Invoke the Unlock procedure to immediately clear the both action lists and end the action history lockdown. Additionally, you can call the Clear procedure anytime to delete all actions from both lists.

The Spreadsheet and Report Designer controls support the undo/redo commands for the following operations:

You can also save a custom action to the undo list by including the action’s code between the BeginAction and EndAction procedure calls.