Articles in this section

How to discard all the changes in 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); 
     }
}

 

Sample: Discard_All_Changes

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied