Hello,
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.
Thanks!
-Paul
AD
Administrator
Syncfusion Team
January 13, 2004 05:02 PM UTC
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.
PL
Paul Laudeman
January 15, 2004 10:47 AM UTC
Clay,
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.GridStyleInfo.get_CellType()
at Syncfusion.Windows.Forms.Grid.GridStyleInfo.get_CellModel()
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?
PL
Paul Laudeman
January 15, 2004 10:54 AM UTC
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.
Thanks,
-Paul
PL
Paul Laudeman
January 15, 2004 11:05 AM UTC
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?
Thanks again.
AD
Administrator
Syncfusion Team
January 15, 2004 01:27 PM UTC
What version are you using? I think this is fixed in our 2.0.1.0 and 2.0.2.0 beta releases.
PL
Paul Laudeman
January 15, 2004 05:06 PM UTC
1.6.1.5
I did find a work around for it. Thanks anyway!