Assume that, a win form has certain input fields and user enters/re-enters some data.
How to retain data previously entered by \'undo\' operation?
Just I wan
I'm not sure if WinForms/.Net has some type of built-in Undo feature that you can take advantage of. But what you are really looking for is a Stack datastructure to help you manage a list of actions. You'll need to create some type of "action" object to represent the actions that a user could do and as they progress through the application you'll need to push these actions onto the Stack. When they hit the undo button, or Ctrl-Z or whatever method of initiating the undo action you'll pop off the current action and restore the application state to the previous action.
This is a very basic and high level overview of how this would work but I imagine that implementing such a feature can get quite complex. Just imagine how it needs to work for a program like Adobe Photoshop. :O
My suggestion is to determine the specific undo requirements and its practical benefits before starting the design and implementation. I inherited a WinForms app that used a multiple operation sequential undo via a stack of generic "action" objects internally. However, it turned out that none of the users of the app I spoke with use nor requested the feature! And the way this particular app works, if I was a user of the app, I just would not see myself using the feature either.
The Undo functionality could have been more useful in this case if it was a 'selective' undo; where the user could select any single operation/edit of several previous edits made, prior to data commit, and restore that single edit to its original state, instead of only being able to undo the last operation first, followed by the second to last operation, etc. which is how it was implemented.
In any case, the app thus contains unneeded complexity and indirection, making it harder and slower to 'grok' and make changes and enhancements to existing functionality, in this case for little or no real-world benefit. Since I inherited the project, I have implemented new features without undo and nobody has had any complaints.
http://blogs.msdn.com/kirillosenkov/archive/2009/06/29/new-codeplex-project-a-simple-undo-redo-framework.aspx