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 GoldRank #50 · 30.6K pointsPosted Feb 8, 2008, 1:35 PM EST
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.
Mike GoldRank #50 · 30.6K pointsPosted Feb 8, 2008, 1:35 PM EST
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.
anamika agrawal16 pointsPosted Feb 10, 2008, 11:26 PM EST