Skip to content

Commit 22c8b87

Browse files
authored
Merge pull request #2 from SyncfusionExamples/ES-975464
ES-975464 - Resolve the ReadMe file length issue in this sample repository
2 parents bbaa532 + 76bff78 commit 22c8b87

1 file changed

Lines changed: 27 additions & 2 deletions

File tree

README.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,27 @@
1-
# how_to_discard_all_changes
2-
This sample explains how to undo and redo all the unsaved changes in Spreadsheet
1+
# How to Discard all the Changes in WPF Spreadsheet?
2+
3+
This sample explains how to undo and redo all the unsaved changes in [WPF Spreadsheet](https://www.syncfusion.com/wpf-controls/spreadsheet) (SfSpreadsheet).
4+
5+
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.
6+
7+
``` c#
8+
//UndoAll the changes
9+
while (this.spreadsheetControl.HistoryManager.UndoStack.Count > 0)
10+
{
11+
var undo = this.spreadsheetControl.HistoryManager.UndoStack.Pop();
12+
if (undo != null)
13+
{
14+
undo.Execute(Syncfusion.UI.Xaml.Spreadsheet.History.CommandMode.Undo);
15+
}
16+
}
17+
18+
//RedoAll the changes
19+
while (this.spreadsheetControl.HistoryManager.RedoStack.Count > 0)
20+
{
21+
var redo = this.spreadsheetControl.HistoryManager.RedoStack.Pop();
22+
if (redo != null)
23+
{
24+
redo.Execute(Syncfusion.UI.Xaml.Spreadsheet.History.CommandMode.Redo);
25+
}
26+
}
27+
```

0 commit comments

Comments
 (0)