How to implement 'undo' operation in .net windows application?

后端 未结 9 1256
无人共我
无人共我 2020-12-04 22:35

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

9条回答
  •  北海茫月
    2020-12-04 23:35

    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.

提交回复
热议问题