windowsforms-16851-controls-and-libraries-spreadsheet-events.md
This topic contains a list of WinForms Spreadsheet events. These events allow you to:
The table below lists events the Spreadsheet control raises in response to user actions.
|
User Action
|
Events
| | --- | --- | |
Create a blank workbook.
|
SpreadsheetControl.DocumentClosing
SpreadsheetControl.InitializeDocument
SpreadsheetControl.VisibleRangeChanged
SpreadsheetControl.EmptyDocumentCreated
SpreadsheetControl.SelectionChanged
| |
Load a workbook.
|
SpreadsheetControl.DocumentClosing
SpreadsheetControl.BeforeImport
SpreadsheetControl.InitializeDocument
SpreadsheetControl.VisibleRangeChanged
SpreadsheetControl.DocumentLoaded
SpreadsheetControl.SelectionChanged
| |
Save a workbook.
|
SpreadsheetControl.BeforeExport
SpreadsheetControl.ModifiedChanged
SpreadsheetControl.PropertyChanged
SpreadsheetControl.DocumentSaved
| |
Print a workbook.
|
SpreadsheetControl.BeforePrintSheet
| |
Insert a new worksheet.
|
SpreadsheetControl.SheetInserted
SpreadsheetControl.ActiveSheetChanging
SpreadsheetControl.ActiveSheetChanged
SpreadsheetControl.VisibleRangeChanged
| |
Click a worksheet’s tab on the Sheet Tab Selector.
|
SpreadsheetControl.ActiveSheetChanging
SpreadsheetControl.ActiveSheetChanged
SpreadsheetControl.VisibleRangeChanged
| |
Rename a worksheet.
|
SpreadsheetControl.SheetRenaming
SpreadsheetControl.SheetRenamed
| |
Delete a worksheet.
|
SpreadsheetControl.SheetRemoving
SpreadsheetControl.ActiveSheetChanged
SpreadsheetControl.SheetRemoved
SpreadsheetControl.VisibleRangeChanged
| |
Scroll a worksheet.
|
SpreadsheetControl.ScrollPositionChanged
SpreadsheetControl.VisibleRangeChanged
| |
Insert columns in a worksheet.
|
SpreadsheetControl.ColumnsInserting
SpreadsheetControl.ColumnsInserted
SpreadsheetControl.ContentChanged
| |
Remove columns from a worksheet.
|
SpreadsheetControl.ColumnsRemoving
SpreadsheetControl.ColumnsRemoved
SpreadsheetControl.ContentChanged
| |
Change the column width.
|
SpreadsheetControl.ColumnWidthChanged
SpreadsheetControl.ContentChanged
| |
Insert rows in a worksheet.
|
SpreadsheetControl.RowsInserting
SpreadsheetControl.RowsInserted
SpreadsheetControl.ContentChanged
| |
Remove rows from a worksheet.
|
SpreadsheetControl.RowsRemoving
SpreadsheetControl.RowsRemoved
SpreadsheetControl.ContentChanged
| |
Change the row height.
|
SpreadsheetControl.RowHeightChanged
SpreadsheetControl.ContentChanged
| |
Freeze rows and columns.
|
SpreadsheetControl.PanesFrozen
SpreadsheetControl.ScrollPositionChanged
SpreadsheetControl.VisibleRangeChanged
| |
Unfreeze rows and columns.
|
SpreadsheetControl.PanesUnfrozen
SpreadsheetControl.ScrollPositionChanged
SpreadsheetControl.VisibleRangeChanged
| |
Expand or collapse row or column groups.
|
SpreadsheetControl.BeforeGroupProcessing
SpreadsheetControl.GroupStateChanging
SpreadsheetControl.GroupStateChanged
SpreadsheetControl.VisibleRangeChanged
SpreadsheetControl.AfterGroupProcessing
| |
Click an outline button for row or column groups.
|
SpreadsheetControl.BeforeGroupProcessing
SpreadsheetControl.BeforeOutlineButtonClick
SpreadsheetControl.AfterOutlineButtonClick
SpreadsheetControl.VisibleRangeChanged
SpreadsheetControl.AfterGroupProcessing
| |
Select cells, rows, columns, or drawing objects on a worksheet.
|
SpreadsheetControl.SelectionChanged
| |
Activate a cell’s in-place editor or formula bar, and begin to edit a cell value.
|
SpreadsheetControl.CellBeginEdit
SpreadsheetControl.CellEditorOpened
| |
Finish editing a cell and close the in-place editor.
|
SpreadsheetControl.CellEndEdit
SpreadsheetControl.CellValueChanged
SpreadsheetControl.ContentChanged
| |
Click Enter on the formula bar to commit a value to a cell.
|
SpreadsheetControl.CellEndEdit
SpreadsheetControl.CellValueChanged
SpreadsheetControl.ContentChanged
SpreadsheetFormulaBar.OkButtonClick
| |
Press the ESC key to cancel the input.
|
SpreadsheetFormulaBar.Rollback
SpreadsheetControl.CellCancelEdit
| |
Click Cancel on the formula bar to cancel the input.
|
SpreadsheetFormulaBar.Rollback
SpreadsheetControl.CellCancelEdit
SpreadsheetFormulaBar.CancelButtonClick
| |
Apply formatting to cells.
|
SpreadsheetControl.ContentChanged
| |
Create a defined name.
|
SpreadsheetControl.DefinedNameValidating
SpreadsheetControl.ContentChanged
| |
Edit a defined name.
|
SpreadsheetControl.DefinedNameEditing
SpreadsheetControl.DefinedNameValidating
SpreadsheetControl.ContentChanged
| |
Remove a defined name.
|
SpreadsheetControl.DefinedNameDeleting
SpreadsheetControl.ContentChanged
| |
Insert an image or chart.
|
SpreadsheetControl.ShapeInserted
SpreadsheetControl.ContentChanged
SpreadsheetControl.SelectionChanged
| |
Remove a drawing object.
|
SpreadsheetControl.ShapeRemoving
SpreadsheetControl.ShapeRemoved
SpreadsheetControl.ContentChanged
SpreadsheetControl.SelectionChanged
| |
Copy the selected cell range.
|
SpreadsheetControl.RangeCopying
SpreadsheetControl.RangeCopied
| |
Copy a drawing object.
|
SpreadsheetControl.ShapesCopying
| |
Paste a cell range copied from the current workbook.
|
SpreadsheetControl.CopiedRangePasting
SpreadsheetControl.CellValueChanged
SpreadsheetControl.CopiedRangePasted
SpreadsheetControl.ContentChanged
SpreadsheetControl.SelectionChanged
| |
Paste data from an external application or a cell’s in-place editor.
|
SpreadsheetControl.ClipboardDataPasting
SpreadsheetControl.ClipboardDataObtained
SpreadsheetControl.CellValueChanged
SpreadsheetControl.ClipboardDataPasted
SpreadsheetControl.ContentChanged
SpreadsheetControl.SelectionChanged
| |
Paste a copied drawing object.
|
SpreadsheetControl.ShapeInserted
SpreadsheetControl.ClipboardDataPasted
SpreadsheetControl.ContentChanged
SpreadsheetControl.SelectionChanged
| |
Drag and drop the selected cell range.
|
SpreadsheetControl.BeforeDragRange
SpreadsheetControl.BeforeDropRange
SpreadsheetControl.CellValueChanged
SpreadsheetControl.AfterDropRange
SpreadsheetControl.ContentChanged
SpreadsheetControl.SelectionChanged
| |
Drag the fill handle to populate the adjacent cells with data.
|
SpreadsheetControl.BeforeDragRange
SpreadsheetControl.BeforeFillRange
SpreadsheetControl.CellValueChanged
SpreadsheetControl.AfterFillRange
SpreadsheetControl.ContentChanged
SpreadsheetControl.SelectionChanged
| |
Insert a comment.
|
SpreadsheetControl.CommentInserting
SpreadsheetControl.CommentInserted
SpreadsheetControl.ContentChanged
SpreadsheetControl.SelectionChanged
| |
Remove a comment.
|
SpreadsheetControl.CommentRemoving
SpreadsheetControl.CommentRemoved
SpreadsheetControl.ContentChanged
SpreadsheetControl.SelectionChanged
| |
Click a hyperlink.
|
SpreadsheetControl.HyperlinkClick
| |
Change the zoom level.
|
SpreadsheetControl.VisibleRangeChanged
SpreadsheetControl.ZoomChanged
| |
Specify or edit document properties.
|
SpreadsheetControl.DocumentPropertiesChanged
| |
Right-click the Spreadsheet control’s visual element.
|
SpreadsheetControl.PopupMenuShowing
|
Use the following events to customize the Spreadsheet control’s appearance and behavior:
|
Events
|
Description
| | --- | --- | |
SpreadsheetControl.CustomDrawCell,
SpreadsheetControl.CustomDrawCellBackground
|
Allow you to customize the cell appearance.
| |
SpreadsheetControl.CustomDrawColumnHeader,
SpreadsheetControl.CustomDrawColumnHeaderBackground
|
Allow you to customize the appearance of column headers.
| |
SpreadsheetControl.CustomDrawRowHeader,
SpreadsheetControl.CustomDrawRowHeaderBackground
|
Allow you to customize the appearance of row headers.
| |
SpreadsheetControl.CustomDrawCommentIndicator
|
Allows you to customize comment indicators.
| |
SpreadsheetControl.CustomDrawFrozenPaneBorder
|
Allows you to customize frozen pane borders.
| |
SpreadsheetControl.CustomCellEdit
|
Allows you to assign a custom in-place editor to a cell.
|
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.
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.
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.
The following events usually fire only for changes performed via the Spreadsheet control’s UI: SpreadsheetControl.ActiveSheetChanged,SpreadsheetControl.SelectionChanged, SpreadsheetControl.CellValueChanged, and so on. Set the WorkbookEventOptions.RaiseOnModificationsViaAPI property to true to raise these events when changes are made in code.