Events
- 4 minutes to read
This topic contains a list of the WPF Spreadsheet events. These events allow you to:
Track User Activity
The table below lists events the Spreadsheet control raises in response to user actions.
Handle Exceptions
Handle the SpreadsheetControl.InvalidFormatException and SpreadsheetControl.UnhandledException events to catch exceptions that the Spreadsheet control does not process.
The SpreadsheetControl.InvalidFormatException event fires when a user attempts to load a document in an unsupported format.
The SpreadsheetControl.UnhandledException event allows you to catch exceptions that can occur when users execute commands via the Spreadsheet’s UI. For instance, when they attempt to save a document to a locked or read-only file.
Track Changes in a Document
The SpreadsheetControl.ContentChanged and SpreadsheetControl.ModifiedChanged events indicate that the current document was modified.
The SpreadsheetControl.ContentChanged event occurs each time the document’s content changes. When you use API methods to specify a cell’s value or format a cell, this leads to significant changes in the internal document model, and the ContentChanged event fires twice.
The SpreadsheetControl.ModifiedChanged event indicates that the current document was modified since it was loaded or last saved and the SpreadsheetControl.Modified property’s value changed. The SpreadsheetControl.ModifiedChanged event is also raised when you save the document because the SpreadsheetControl.Modified property’s value changes to false.
Track Modifications in Code
The Spreadsheet control raises events in response to changes in code. For instance, the SpreadsheetControl.PropertyChanged event fires each time a SpreadsheetControl‘s property changes. The SpreadsheetControl.UnitChanging and SpreadsheetControl.UnitChanged events fire when you use the SpreadsheetControl.Unit or ISpreadsheetComponent.Unit property to change the document’s measurement unit. If you set the SpreadsheetControl.ReadOnly property for the control, the SpreadsheetControl.ReadOnlyChanged event occurs.
There are events that usually fire only for changes performed via the Spreadsheet control’s UI: SpreadsheetControl.ActiveSheetChanged,SpreadsheetControl.SelectionChanged, SpreadsheetControl.CellValueChanged, and so on. Set the SpreadsheetControlOptions.RaiseEventsOnModificationsViaAPI property to true to raise these events when changes are made in code.