如何在C#中开发有效的撤销操作? [英] How to Develop a effective undo operation in C#?

查看:333
本文介绍了如何在C#中开发有效的撤销操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi Team,

I want to move Last few changes If I click Undo button in GUI Level.

Page having Two Different Sections,
Section 1: 
            Data Grid View Control (for Displaying all Customer Detail with Editing Option)

Section 2: 
            Data Grid View Control (for Displaying all Store Detail with Editing Option)

Explain:
       Now I edited few records in Customer Data Gridview, once I saved these records in this Section 1; Then I moved to Section 2 Store Details for edit some records. 
User want to move/see last few changes using Undo Operation, How to see the user changes in clicking Undo option.

---
How to implement undo option in this scenario, 



先谢谢。


Thanks in Advance.

推荐答案

您正在寻找的是 Memento模式 [ ^ ]。



实现这种模式并不是很难,诀窍是跟踪你的变化以及撤消这些变化的能力。



以下是一些示例,可在此网站上找到:

纪念品设计模式 [ ^ ]

Generic Memento Pattern对于C#中的Undo-Redo [ ^ ]

C#中的多级撤销和重做实现 - 第一部分(使用单个对象表示变更方法) [ ^ ]

C#中的多级撤消和重做实现 - 第二部分(使用命令模式) ) [ ^ ]

Multilevel C#中的撤消和重做实现 - 第III部分(使用Memento模式) [ ^ ]
What you're looking for is called a Memento pattern[^].

It's not really difficult to implement such pattern, the trick is to keep tracking your changes and the ability to undo those changes.

Here are some examples, available on this very site:
Memento Design Pattern[^]
Generic Memento Pattern for Undo-Redo in C#[^]
Multilevel Undo and Redo Implementation in C# - Part I (Using Single Object Representing Change Approach)[^]
Multilevel Undo and Redo Implementation in C# - Part II (Using Command Pattern)[^]
Multilevel Undo and Redo Implementation in C# - Part III (Using Memento Pattern)[^]


这篇关于如何在C#中开发有效的撤销操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆