Hi. I am using WinForms v17.2 and have a UltraWinGrid with about 5000 rows and 90 columns. Many of the columns are calculated asynchronously with formulas set via the CalcManager. Before doing any operations, like export, I need to make sure all the calculations are done. This is the code, which should ensure this, but it's not working for some reason. What am I missing?
Dim CalcManager As Infragistics.Win.UltraWinCalcManager.UltraCalcManager = Me.MyGrid.CalcManager CalcManager.DeferredCalculationsEnabled = False CalcManager.CalcFrequency = UltraWinCalcManager.CalcFrequency.Manual CalcManager.DirtyAllFormulas() CalcManager.ReCalc() CalcManager.DeferredCalculationsEnabled = True CalcManager.CalcFrequency = UltraWinCalcManager.CalcFrequency.Asynchronous
Me.MyGrid.Refresh() Me.MyGrid.UpdateData()
Thanks in advance!
Hello Michael,
Thank you for contacting Infragistics. The CalcManager exposes a CalculationsCompleted event you can hook, which is fired when all calculations are completed. You can call the calcManager's NotifyValueChanged method and pass the grid and keep track of the this yourself. On a side note, I am not sure when you are creating your formulas. But we advertise using the grid's InitializeLayout.
Let me know if you have any questions.
Hi Michael. Thanks for responding.
I can see that the CalculationsCompleted event fires right after the ReCalc call is made. This is not expected since I know it takes about 50 seconds to recalculate the whole grid. I know the formulas are working since ValueDirtied and CalculationsCompleted events are fired as I scroll down the grid and new rows become visible.
I was able to fool the grid to recalculate by forcing a sort on a calculated column (takes about 50s). However, this is not a great solution, but I still can't figure out why the ReCalc code above is not working as it should. What else could prevent the CalcManager from recalculating the formulas?
Thank you for following up. Please refer to the sample attached that utilizes the following reworked logic. (see the click event of button2):
Reassigning the CalcManager appears to have worked. Thank you for your help!