Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,27 @@
# how_to_discard_all_changes
This sample explains how to undo and redo all the unsaved changes in Spreadsheet
# How to Discard all the Changes in WPF Spreadsheet?

This sample explains how to undo and redo all the unsaved changes in [WPF Spreadsheet](https://www.syncfusion.com/wpf-controls/spreadsheet) (SfSpreadsheet).

By default, all the unsaved changes are maintained in the **UndoStack** commands collection. To discard all the unsaved changes programmatically, **Execute** the all commands in **UndoStack** collection. By executing the commands in **RedoStack** commands collection, all the discarded changes can be retrieved.

``` c#
//UndoAll the changes
while (this.spreadsheetControl.HistoryManager.UndoStack.Count > 0)
{
var undo = this.spreadsheetControl.HistoryManager.UndoStack.Pop();
if (undo != null)
{
undo.Execute(Syncfusion.UI.Xaml.Spreadsheet.History.CommandMode.Undo);
}
}

//RedoAll the changes
while (this.spreadsheetControl.HistoryManager.RedoStack.Count > 0)
{
var redo = this.spreadsheetControl.HistoryManager.RedoStack.Pop();
if (redo != null)
{
redo.Execute(Syncfusion.UI.Xaml.Spreadsheet.History.CommandMode.Redo);
}
}
```