Skip to main content
A newer version of this page is available. .

Events

  • 4 minutes to read

This topic provides a comprehensive list of events raised in the SpreadsheetControl. All events are grouped into five categories, according to the functions they perform:

Track User Activity

The table below lists the sequence of events that are raised when an end-user performs a particular operation in the SpreadsheetControl. While it is not a comprehensive list of all end-user actions, it details events for the most common operations performed by an end-user.

User Action

Event

Create a blank workbook.

SpreadsheetControl.DocumentClosing

SpreadsheetControl.InitializeDocument

SpreadsheetControl.EmptyDocumentCreated

SpreadsheetControl.SelectionChanged

SpreadsheetControl.UpdateUI

Load a workbook.

SpreadsheetControl.DocumentClosing

SpreadsheetControl.BeforeImport

SpreadsheetControl.InitializeDocument

SpreadsheetControl.DocumentLoaded

SpreadsheetControl.SelectionChanged

SpreadsheetControl.UpdateUI

Save a workbook.

SpreadsheetControl.BeforeExport

SpreadsheetControl.ModifiedChanged

SpreadsheetControl.PropertyChanged

Print a workbook.

SpreadsheetControl.BeforePrintSheet

Insert a new worksheet.

SpreadsheetControl.SheetInserted

SpreadsheetControl.ActiveSheetChanging

SpreadsheetControl.ActiveSheetChanged

SpreadsheetControl.UpdateUI

Click a worksheet tab in the Sheet Tab Selector.

SpreadsheetControl.ActiveSheetChanging

SpreadsheetControl.ActiveSheetChanged

SpreadsheetControl.UpdateUI

Rename a worksheet.

SpreadsheetControl.SheetRenaming

SpreadsheetControl.SheetRenamed

SpreadsheetControl.UpdateUI

Delete a worksheet.

SpreadsheetControl.ActiveSheetChanged

SpreadsheetControl.SheetRemoved

SpreadsheetControl.UpdateUI

Insert columns in a worksheet.

SpreadsheetControl.ColumnsInserted

SpreadsheetControl.ContentChanged

SpreadsheetControl.UpdateUI

Remove columns from a worksheet.

SpreadsheetControl.ColumnsRemoved

SpreadsheetControl.ContentChanged

SpreadsheetControl.UpdateUI

Insert rows in a worksheet.

SpreadsheetControl.RowsInserted

SpreadsheetControl.ContentChanged

SpreadsheetControl.UpdateUI

Remove rows from a worksheet.

SpreadsheetControl.RowsRemoved

SpreadsheetControl.ContentChanged

SpreadsheetControl.UpdateUI

Freeze rows and columns.

SpreadsheetControl.PanesFrozen

SpreadsheetControl.UpdateUI

Unfreeze rows and columns.

SpreadsheetControl.PanesUnfrozen

SpreadsheetControl.UpdateUI

Select cells, ranges, rows, columns or shapes on a worksheet.

SpreadsheetControl.SelectionChanged

SpreadsheetControl.UpdateUI

Activate the cell’s in-place editor or Formula Bar, and begin editing cell content.

SpreadsheetControl.CellBeginEdit

SpreadsheetControl.UpdateUI

Finalize the modification of cell content and close the in-place editor.

SpreadsheetControl.CellEndEdit

SpreadsheetControl.CellValueChanged

SpreadsheetControl.ContentChanged

SpreadsheetControl.UpdateUI

Finalize the modification of cell content by clicking the Enter button on the Formula Bar.

SpreadsheetControl.CellEndEdit

SpreadsheetControl.CellValueChanged

SpreadsheetControl.ContentChanged

SpreadsheetFormulaBarControl.OkButtonClick

SpreadsheetControl.UpdateUI

Cancel the input by pressing the ESC key.

SpreadsheetFormulaBarControl.Rollback

SpreadsheetControl.CellCancelEdit

SpreadsheetControl.UpdateUI

Cancel the input by clicking the Cancel button on the Formula Bar.

SpreadsheetFormulaBarControl.Rollback

SpreadsheetControl.CellCancelEdit

SpreadsheetFormulaBarControl.CancelButtonClick

SpreadsheetControl.UpdateUI

Apply formatting options to cells.

SpreadsheetControl.ContentChanged

SpreadsheetControl.UpdateUI

Click a hyperlink.

SpreadsheetControl.HyperlinkClick

Zoom in or out of a worksheet.

SpreadsheetControl.ZoomChanged

SpreadsheetControl.UpdateUI

Right-click a visual element of the SpreadsheetControl.

SpreadsheetControl.PopupMenuShowing

Custom Draw

The SpreadsheetControl provides numerous custom draw events that allow you to customize document appearance. To custom paint worksheet cells, use the SpreadsheetControl.CustomDrawCell and SpreadsheetControl.CustomDrawCellBackground events. To custom draw row and column headings, handle the SpreadsheetControl.CustomDrawRowHeader, SpreadsheetControl.CustomDrawRowHeaderBackground, SpreadsheetControl.CustomDrawColumnHeader and SpreadsheetControl.CustomDrawColumnHeaderBackground events. To custom paint frozen pane borders in the SpreadsheetControl, handle the SpreadsheetControl.CustomDrawFrozenPaneBorder event.

Note that custom painting is not saved in a workbook file.

Handle Exceptions

You can catch exceptions that are not processed by the SpreadsheetControl by handling the SpreadsheetControl.InvalidFormatException and SpreadsheetControl.UnhandledException events. Use the SpreadsheetControl.InvalidFormatException event to handle exceptions raised when an end-user tries to load a document in an unsupported format. The SpreadsheetControl.UnhandledException event allows you to catch exceptions that may occur when an end-user executes a command via the SpreadsheetControl UI. For example, use this event to prevent the application from crashing when an end-user attempts to save a document to a read-only or locked file.

Track Changes to the Document Content

There are two events indicating that the current document has been modified: SpreadsheetControl.ContentChanged and SpreadsheetControl.ModifiedChanged. The SpreadsheetControl.ContentChanged event occurs each time the document content has been changed. When you use API methods to assign a value or apply formatting options to a worksheet cell, it leads to significant changes in the internal document model, and the event fires twice. The SpreadsheetControl.ModifiedChanged event indicates that the current document was modified for the first time since it was loaded or last saved, and the SpreadsheetControl.Modified property has been changed. This property can be used by validation or data-saving methods to determine if a workbook has been modified, so that its content is either validated or saved. Saving the current document also raises the SpreadsheetControl.ModifiedChanged event, since the SpreadsheetControl.Modified property reverts to false. Changing the SpreadsheetControl.Modified property value fires the SpreadsheetControl.PropertyChanged event, which occurs each time a property of the SpreadsheetControl class is modified.

Track Modifications Performed via API

Some events can be raised in response to modifications performed in code. The SpreadsheetControl.UnitChanging and SpreadsheetControl.UnitChanged events fire when the document units of measurement have been changed via the SpreadsheetControl.Unit or ISpreadsheetComponent.Unit property. When you use the SpreadsheetControl.ReadOnly property to prohibit or allow document modifications in the SpreadsheetControl, the SpreadsheetControl.ReadOnlyChanged event occurs. Use the SpreadsheetControl.BeforeDispose event to take the necessary steps for saving changes before the SpreadsheetControl instance is removed from memory.

Some events are normally raised only for changes made with the SpreadsheetControl UI (SpreadsheetControl.ActiveSheetChanged, SpreadsheetControl.ColumnsInserted, SpreadsheetControl.ColumnsRemoved, SpreadsheetControl.SelectionChanged, etc.), but you can fire them when modifications are made to a document via an API. To do this, set the WorkbookEventOptions.RaiseOnModificationsViaAPI property to true.