I''m curious to know how I can catch an event or otherwise be notified when a formula cell type is or has been updated.
Specifically, I''d like to be able to capture the new value that is computed as soon as it changes so I can persist the result of the formula.
ADAdministrator Syncfusion Team January 13, 2004 12:02 PM
SaveCelInfo is one place you can try to do this. But it is fired for all cells, so you would have to check e.Style.CellType or e.Style.FormulaTag to see if the cell is a formula cell.
Another problem is that the engine normally only computes the values when they are needed. So, if you make a change that affects 1000 cells that are not displayed currently, those 1000 cells are not recomputed until thay are needed. So, the idea of persisting all computed values needs to be thought through as the default behavior may not recompute all cells.
If you want to force all cells to be computed, and you are storing the values in the grid itself (not using it virtually), then you can call engine.RecalculateRange passing in the whole grid and setting the second parameter to true.
PLPaul LaudemanJanuary 15, 2004 05:47 AM
I was experimenting with the RecalculateRange method, but when I try to run it I get the following exception:
Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
at Syncfusion.Styles.StyleInfoBase.GetValue(StyleInfoProperty sip)
at Syncfusion.Windows.Forms.Grid.GridFormulaEngine.RecalculateRange(GridRangeInfo range, Boolean forceCalculations)
at Syncfusion.Windows.Forms.Grid.GridFormulaCellModel.RecalculateRange(GridRangeInfo range, Boolean forceCalculations)
Do you know what might be causing this exception?
PLPaul LaudemanJanuary 15, 2004 05:54 AM
From digging through the grid source, it looks like the GridFormulaCell class is throwing an exception in the RecalculateRange method (line 930) because for whatever reason the GridStyleInfo of the cell is null and when the code attempts to access the CellModel it can''t.
PLPaul LaudemanJanuary 15, 2004 06:05 AM
Oops, I meant to say that the CellModel property is null, not the GridStyleInfo object.
Is there a fix or work around available for this issue?
ADAdministrator Syncfusion Team January 15, 2004 08:27 AM
What version are you using? I think this is fixed in our 184.108.40.206 and 220.127.116.11 beta releases.
PLPaul LaudemanJanuary 15, 2004 12:06 PM
I did find a work around for it. Thanks anyway!