Besides being a container for formula cells, the sheet is property notified when its content changes and fires several events, which you can use. These events are:
SectionsChanged - fired when the sections maintained by the sheet have changed (the sender argument is a reference to the sheet)
SectionRowsChanged - fired when the rows of a section in this sheet have changed (the sender argument is a reference to the the section)
SectionCellsChanged - fired when the cells of a section in this sheet have changed (the sender argument is a reference to the the section)
RowCellsChanged - fired when the cells of a row in a section of this sheet have changed (the sender argument is a reference to the row)
CellChanged - fired when a cell has changed (the sender argument is a reference to the cell)
CellsChanged - fired when a multiple cells from the sheet have changed (the sender argument is a reference to the sheet)
Changed - fired when the sheet has changed (the sender argument is a reference to the sheet). This event is fired after any of the above events.
It is often required to perform several changes in the sheet at a time. In order to optimize the sheet performance, you can use the BeginUpdate and EndUpdate methods.
C# |
Copy Code
|
sheet.BeginUpdate();
// do sheet changes here
sheet.EndUpdate();
|
Visual Basic |
Copy Code
|
sheet.BeginUpdate()
' do sheet changes here
sheet.EndUpdate()
|
The default implementation of these methods locks/unlocks the events, which the sheet fires and locks/unlocks the cache invalidation. You can also do this manually with the help of the
LockEvents and
LockCacheInvalidation properties.
Some formula sheets can cache the precalculated content of some of their sections (for example the shape sheet caches a matrix, which represents the content of its transform section). The proper place to mark any cached content as invalid is in an override of the
InvalidateCache virtual method. The
NFormulaSheet class will properly call it when the cache may not already be up to date.
Visually the formula sheet is edited with verbs. The verbs, which the sheet supports can be obtained from the
GetVerbs method.