We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Resetting Dependencies

I''m using the CalcEngine with an object implementing the ICalcData interface. Each object implementing ICalcData represents a column in a grid, so I call oCalcEngine.RegisterGridAsSheet for each of these objects. The user can reset the size of objects implementing ICalcData so the dependencies need to change. After this reset, i.e. the second time the "grid" is used for calculations after the program was started, the calc engine calls SetValueRowCol before I expect it to. It seems that the engine "remembers" the prior dependencies. I tried calling CalcEngine.CreateSheetFamilyID again along with creating a new CalcEngine and registering the sheets again, but the behavior is still there. How can I be sure to clear all the dependencies the CalcEngine knows about and start over?

11 Replies

AD Administrator Syncfusion Team October 14, 2005 02:58 PM UTC

Try calling Engine.DependentCells.Clear and Engine.DependentFormulaCells.CLear to see if that does waht you need.


KL Ken Law October 14, 2005 09:34 PM UTC

Thanks, that worked as a fix for a symptom of our problem, but did not fix the more severe part of the problem. When we reset everything and are going from a small grid to a larger one, a Standard Deviation formula seems to compute a much larger number than it should. I''ve put breakpoints at GetValueRowCol, SetValueRowCol and where I call ValueChanged to verify the correct formula is being put in and the correct values are being accessed. When SetValueRowCol gives me an updated value, it is wrong (too large). Any ideas? I''m using 3.2.1.0 - are there any known calc problems with that release?


AD Administrator Syncfusion Team October 14, 2005 10:41 PM UTC

Can you upload a sample project showing this problem?


AD Administrator Syncfusion Team October 15, 2005 07:48 AM UTC

One other question. Are you calling the static method CalcEngine.UnregisterGridAsSheet to unregister the object before your re-register it?


KL Ken Law October 15, 2005 10:55 AM UTC

No, I was not calling the CalcEngine.UnregisterGridAsSheet method, but I am creating a new CalcEngine object. I will try this first. Thanks.


KL Ken Law October 15, 2005 12:19 PM UTC

Another question. The instance constructor for CalcEngine takes an object implementing ICalcData in its parameter named "ParentObject". I simply pass the first ICalcData object in my collection to this constructor, then I pass the same object again along with all other ICalcData objects in the collection to this.oCalcEngine.RegisterGridAsSheet(..). Does that seem OK? What is the purpose of the ParentObject parameter? Each of my ICalcData objects represents a single column in the grid and there are no cross-references between them. I display the data using a virtual grid.


AD Administrator Syncfusion Team October 15, 2005 12:39 PM UTC

You should pass each instance of your ICalcData objects through a RegisterGridAsSheet call. So, if you have 5 ICalcData objects, you should register each of them as a sheet. The reason is that this sets ups a unique id tied to th esheet. So, cell A1 in one object can be distinguished from cell A1 in another object as far as dependencies go. Without this, the CalcEngine may be pulling the value from some other sheet when reference A1. Then when you want to remove a sheet, you call the unregister method.


KL Ken Law October 17, 2005 06:39 PM UTC

I''m getting the following exception when trying to call RegisterGridAsSheet after calling UnregisterGridAsSheet: Unhandled Exception: System.ArgumentException: Item has already been added. Key in dictionary: "VMTResultDataMSA.GRRTestResults" Key being added: "VMTResultDataMSA.GRRTestResults" at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add) at System.Collections.Hashtable.Add(Object key, Object value) at Syncfusion.Calculate.CalcEngine.RegisterGridAsSheet(String refName, ICalcData model, Int32 sheetFamilyID) Here is my code: foreach (object o in this.alRDTestDefs) { grrTestResults = (GRRTestResults)o; CalcEngine.UnregisterGridAsSheet(grrTestResults.ID, grrTestResults); } CalcEngine.ResetSheetFamilyID(); this.iSheetFamilyID = CalcEngine.CreateSheetFamilyID(); //oCalcEngine = new CalcEngine(grrTestResults); //oCalcEngine.UseDependencies = true; this.oCalcEngine.ResetVariableNames(); foreach (object o in this.alRDTestDefs) { grrTestResults = (GRRTestResults)o; oCalcEngine.RegisterGridAsSheet(grrTestResults.ID, grrTestResults, this.iSheetFamilyID); } The strange thing about the exception message is it says I''m trying to add key: "VMTResultDataMSA.GRRTestResults" which is a type, not the id string grrTestResults.ID I''m passing to RegisterGridAsSheet.


AD Administrator Syncfusion Team October 17, 2005 10:27 PM UTC

There are other collections that need to be cleared. Here is a little sample. http://www.syncfusion.com/Support/user/uploads/Calculate_Unregister_caed203f.zip


KL Ken Law October 18, 2005 12:57 PM UTC

Thanks very much Clay. I''m on the road today but will try this out tommorrow.


KL Ken Law October 22, 2005 09:13 PM UTC

Clay, Thanks so much. I made the changes to my program based on your sample program and the problems seem to be fixed. Ken

Loader.
Live Chat Icon For mobile
Up arrow icon