使用撤消和重做功能
Contents
[
Hide
]
GridDesktop的撤消/重做功能非常有用。名称自己解释了它的功能,它允许您在工作表中撤消/重做最近的操作。例如,如果一个公式被意外删除或者您编辑了一个您实际上不想要的单元格中的数据,这些操作可以通过控件提供的撤消和重做操作来纠正。
执行撤消和重做操作
以下API用于此任务。每个API都附有描述,请查阅。
- GridDesktop.EnableUndo - 属性: 它指示是否启用了撤消功能,默认值为"false"。
- UndoManager – 类: 用于管理撤消/重做操作。
- GridDesktop.UndoManager – 属性: 获取UndoManager对象的实例。
- UndoManager.Undo – 方法: 执行撤消操作。
- UndoManager.Redo - 方法: 执行重做操作。
- UndoManager.ClearStack – 方法: 清除撤销/恢复栈。
- UndoManager.UndoStepsCount – 属性: 获取当前可用的撤销步数。
- UndoManager.RedoStepsCount – 属性: 获取当前可用的重做步数。
- UndoManager.UndoStackSize – 属性: 获取/设置撤销栈的大小。
撤销
以下示例代码展示如何使用GridDesktop API实现撤销操作。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// Enable the Undo operation | |
gridDesktop1.EnableUndo = true; | |
// Create the UndoManager object | |
UndoManager um = gridDesktop1.UndoManager; | |
// Perform Undo operation | |
um.Undo(); |
重做
以下示例代码展示如何使用GridDesktop API实现重做操作。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// Create the UndoManager object | |
UndoManager um = gridDesktop1.UndoManager; | |
// Perform Redo operation | |
um.Redo(); |
当前, 撤销/重做操作是指单元格值的更改。