元に戻すおよびやり直しの機能を使用する
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(); |
現在、元に戻し/やり直し操作はセルの値の変更を指します。