Skip to content

Undo and redo

anamika agrawal

Asked Feb 7, 2008, 8:32 PM EST2 answers
Share
LinkedInX
how undo and  redo,cut paste can be implemented in  c#

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Mike Gold
    0

    if you are using an edit control, this is already built into the TextBox control (for example).

    But your question needs to be much more specific to answer it.  For example, what are you pasting text? images?  What are you undoing, what kind of actions?  insertion of text?  database insertions?  remote calls across the internet? 

    What sort of depth do you need for undo redo?  Single undo? Single redo?  Multiple undo/redo?

    undo and redo is tricky.  The easiest way I've seen is to build a stack (you can use the stack collection)  of states of your program.  Then push each state of your program on the stack using some "checkpoint" in your code.  When the user hits undo pop the state of the program from the stack.  The tricky part is of course how do you save the state of your program.  If it's a drawing, then you can save the drawing (for example).  If the state of your program can be maintained using code structures of some kind, then you can put these on the stack.

    0
  • 0
    thxfor replying  me actually i m making a excel spreadsheet......i have implementedit already
    0