New to Telerik UI for WPF? Download free 30-day trial

Save Executed Event in RadSpreadsheet

Environment

Product RadSpreadsheet for WPF
Version 2024.3.924

Description

How to listen for the save file command of RadSpreadsheet for WPF.

Solution

To do this, you can subscribe to the UICommandExecuted event of the RadWorksheetEditor object.

RadWorksheetEditor editorCache = null; 
 
private void RadSpreadsheet_ActiveSheetEditorChanged(object? sender, EventArgs e) 
{ 
    var spreadsheet = (RadSpreadsheet)sender; 
    if (editorCache != null) 
    { 
        editorCache.UICommandExecuted -= ActiveSheetEditor_UICommandExecuted; 
    } 
    if (spreadsheet.ActiveWorksheetEditor != null) 
    { 
        spreadsheet.ActiveWorksheetEditor.UICommandExecuted += ActiveSheetEditor_UICommandExecuted; 
    } 
    editorCache = spreadsheet.ActiveWorksheetEditor; 
} 
 
private void ActiveSheetEditor_UICommandExecuted(object? sender, Telerik.Windows.Controls.Spreadsheet.Commands.UICommandExecutedEventArgs e) 
{ 
    var editor = (RadWorksheetEditor)sender; 
    if (editor.Commands.SaveFile == e.Command) 
    { 
      // execute your code here 
    } 
} 
In this article