Undo/Redo Methods

Posted by: fhcnunes-fp on 8 September 2017, 12:33 pm EST

  • Posted 8 September 2017, 12:33 pm EST

    Hello,
    Could someone help me with undo/redo functions? I need to implement these functionalities in my application, but I do not know how I can do it. A basic example would help me a lot.
    Thanks.
  • Replied 8 September 2017, 12:33 pm EST

    We are working on finalizing the documentation for the undo/redo feature. Undo and Redo are fields in the SpreadAction class. You might have already found this:

    By default, undo and redo are enabled in the component, and end-users can activate the undo and redo through the standard keyboard shortcut keys CTRL+Z and CTRL+Y, respectively. Here is a list of the user actions for which an undo or redo can be performed:

      Auto-sort of column (by clicking on the column header)

      Cell or cell range drag-drop

      Cell edit

      Clipboard cut (data only)

      Clipboard cut

      Clipboard paste

      Column move

      Column or columns width change (resize)

      Row move

      Row or rows height change (resize)

      Shape object or cell note changed

      Shape object changed through keyboard interface actions:

      Delete: DELETE

      Move up: UP

      Move down: DOWN

      Move left: LEFT

      Move right: RIGHT

      Increase width: CTRL + RIGHT

      Decrease width: CTRL + LEFT

      Increase height: CTRL + DOWN

      Decrease height: CTRL + UP

      Rotate clockwise: ALT + RIGHT

      Rotate counterclockwise: ALT + LEFT

    We were not planning on including documentation for customizing the UndoRedo functionality in this release. Are you trying to customize the feature or simply perform an Undo and a Redo?

  • Replied 8 September 2017, 12:33 pm EST

    Hi,

    Adding support for undo/redo using Spread for Windows Forms version 3 is not difficult.  Most users will simply want to add menu items for the Undo and Redo actions, which only requires calling into the new methods to perform the actions (FpSpread.UndoManager.Undo and FpSpread.UndoManager.Redo).  As Bill notes above, this is not really necessary since the control automatically supports undo and redo through the usual keyboard shortcuts, CTRL+Z and CTRL+Y, respectively.

    There are more things you can do if you choose.  UndoManager has methods that will return the list of pending undo or redo actions, and you can roll back to a particular action in the undo list, or forward to a particluar action in the redo list with calls to overloaded Undo and Redo methods.  So you could display a list of actions and let the user choose which one to roll back or forward to, in a menu, listbox, or other control.

    You can perform undo actions in code too, as Bob notes above, by creating the appropriate UndoAction object and passing it to the PerformUndoAction method in UndoManager.  The classes for the undo actions are in the FarPoint.Win.Spread.UndoRedo namespace.

    You can even create your own custom UndoAction class, and write code to implement the PerformUndoAction, Undo, and Redo methods to do whatever you want.  Your class can then be added to the Spread's Action map with SpreadView.GetActionMap().Put() and then you can map that action to a specific key combination in the Spread's input maps for the operation modes that you want the action to work in.  How to use the action and input maps to control how Spread maps key combinations to actions is described here.
  • Replied 8 September 2017, 12:33 pm EST

    Hello,
    I have downloaded Spread for Windows Forms version 3 beta to use Undo/Redo methods. But my Visual Studio 2005 do not recognize FpSpread.UndoManager. Error message says "Type 'FarPoint.Win.Spread.UndoRedo.CellEditUndoAction' is not defined" and "'UndoManager' is not a member of 'FarPoint.Win.Spread.FpSpread". Is there some settings? What must I do? I have just inserted the code in Undo calling.

    Spread for Windows Forms version 3 2005 was installed correctly and my computer was reinitiated.
    Thanks.

  • Replied 8 September 2017, 12:33 pm EST

    fhcnunes -

    Prior to the release of the beta for version 3 there was no undo/redo functions.  In the current version 3 RC1 you can do it like this...

    Dim action As New FarPoint.Win.Spread.UndoRedo.CellEditUndoAction(FpSpread1.ActiveSheet, 1, 1, "", False)
    FpSpread1.UndoManager.PerformUndoAction(action)

    This would undo a recently edited cell.  There are many other actions that are part of undo/redo functionality.
  • Replied 8 September 2017, 12:33 pm EST

    Bob,
    Which release are you speaking? I am using Spread for Windows Forms for VS2005 2.5 update, but I am finding nothing about undo/redo functions. You said me to use the current version 3 RC1. Which update does this version belong to? Am I correct in using Spread for Windows Forms for VS2005 2.5? Is there another update to use undo/redo functions?
    Thanks.
  • Replied 8 September 2017, 12:33 pm EST

    In the version you are using there is no undo/redo functionality.  We've added it to version 3 which is now in beta.  You can apply to participate in the beta by contacting beta@fpoint.com.
  • Replied 8 September 2017, 12:33 pm EST

    Hello,
    I would like to know which methods I can use to implement undo/redo funcionalities. I have downloaded beta version 3 of FarPoint. Is there some documentation? If so, could you send me the hiperlink?
    Thanks.
  • Replied 8 September 2017, 12:33 pm EST

    Hello,

    Do you have the AllowUndo set to True?
  • Replied 8 September 2017, 12:33 pm EST

    It sounds like you are referencing the wrong version of the control.  Do you have other versions of Spread installed?  Please try deleting the references to the Spread assemblies from your project and re-adding them by browsing to the install folder where the version 3 assemblies are installed.
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels