Using Undo and Redo Feature

Performing Undo and Redo Operation

The following APIs are available for the task. The description is given with each API, please check them.

  • GridDesktop.EnableUndo - attribute: It indicates whether the Undo function is enabled, the default value is “false”.
  • UndoManager – class: It is used to manage the undo/redo operation.
  • GridDesktop.UndoManager – attribute: It gets the instance of the UndoManager object.
  • UndoManager.Undo – method: It performs an undo operation.
  • UndoManager.Redo - method: It performs the redo operation.
  • UndoManager.ClearStack – method: It clears the undo/redo stack.
  • UndoManager.UndoStepsCount – attribute: It gets the count of current available undo steps.
  • UndoManager.RedoStepsCount – attribute: It gets the count of current available redo steps.
  • UndoManager.UndoStackSize – attribute: It gets/sets the undo stack size.

Undo

The following sample code shows how to implement the Undo operation using the GridDesktop API.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Enable the Undo operation
gridDesktop1.EnableUndo = true;
// Create the UndoManager object
UndoManager um = gridDesktop1.UndoManager;
// Perform Undo operation
um.Undo();

Redo

The following sample code shows how to implement the Redo operation using the GridDesktop API.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Create the UndoManager object
UndoManager um = gridDesktop1.UndoManager;
// Perform Redo operation
um.Redo();