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.
Unfortunately, activation email could not send to your email. Please try again.

Resetting Dependencies

Thread ID:





35932 Oct 14,2005 06:40 AM Oct 22,2005 05:13 PM Windows Forms 11
Tags: Calculate
Ken Law
Asked On October 14, 2005 06:40 AM

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?

Administrator [Syncfusion]
Replied On October 14, 2005 10:58 AM

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

Ken Law
Replied On October 14, 2005 05:34 PM

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 - are there any known calc problems with that release?

Administrator [Syncfusion]
Replied On October 14, 2005 06:41 PM

Can you upload a sample project showing this problem?

Administrator [Syncfusion]
Replied On October 15, 2005 03:48 AM

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

Ken Law
Replied On October 15, 2005 06:55 AM

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

Ken Law
Replied On October 15, 2005 08:19 AM

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.

Administrator [Syncfusion]
Replied On October 15, 2005 08:39 AM

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.

Ken Law
Replied On October 17, 2005 02:39 PM

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.

Administrator [Syncfusion]
Replied On October 17, 2005 06:27 PM

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

Ken Law
Replied On October 18, 2005 08:57 AM

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

Ken Law
Replied On October 22, 2005 05:13 PM

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


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.