SuspendCalc は、ResumeCalc が次に呼び出されるまで、UltraCalcManager が実行する自動計算を中断します。
中断するのは、自動的に実行される計算のみです。つまり、タイマーに従って実行される計算 (CalcFrequency が Asynchronous に設定されている場合) と、コントロールの値がダーティになったときの変更通知に従って実行される計算 (CalcFrequency が Synchronous に設定されている場合) は、どちらも中断されます。ReCalc メソッドまたは Infragistics.Win.CalcEngine.IUltraCalcManager.EnsureCalculated(Infragistics.Win.CalcEngine.IUltraCalcReference,System.Boolean) メソッドを明示的に呼び出した場合も計算は実行されます。
SuspendCalcが呼び出されるたびにカウンタが増える点にも注意してください。計算を再開する前に ResumeCalc を同じ回数呼び出す必要があります。
Imports Infragistics.CalcEngine Imports Infragistics.Win.UltraWinCalcManager Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Suspend calculation while we are adding new items into the calc network Me.UltraCalcManager1.SuspendCalc() Dim calcSettings As CalcSettings 'Set CalcSettings properties on TextBox1 calcSettings = Me.UltraCalcManager1.GetCalcSettings(Me.textBox1) calcSettings.PropertyName = "Text" calcSettings.Alias = "Height" calcSettings.ErrorValue = 1 'Set CalcSettings properties on TextBox2 calcSettings = Me.UltraCalcManager1.GetCalcSettings(Me.textBox2) calcSettings.PropertyName = "Text" calcSettings.Alias = "Width" calcSettings.ErrorValue = 1 'Create a NamedReference to calulate the area. Dim namedReference As NamedReference namedReference = Me.UltraCalcManager1.NamedReferences.Add("Area", "[//Height] * [//Width]") namedReference.ErrorValue = "Error" 'Everything is added, so resume Me.UltraCalcManager1.ResumeCalc() End Sub Private Sub UltraCalcManager1_CalculationsCompleted(ByVal sender As Object, ByVal e As System.EventArgs) Handles UltraCalcManager1.CalculationsCompleted If (Me.UltraCalcManager1.NamedReferences.Exists("Area")) Then Me.textBox3.Text = Me.UltraCalcManager1.NamedReferences("Area").FormulaResult.Value.ToString() End If End Sub
using Infragistics.CalcEngine; using Infragistics.Win.UltraWinCalcManager; private void Form1_Load(object sender, System.EventArgs e) { //Suspend calculation while we are adding new items into the calc network this.ultraCalcManager1.SuspendCalc(); CalcSettings calcSettings = null; //Set CalcSettings properties on TextBox1 calcSettings = this.ultraCalcManager1.GetCalcSettings(this.textBox1); calcSettings.PropertyName = "Text"; calcSettings.Alias = "Height"; calcSettings.ErrorValue = 1; //Set CalcSettings properties on TextBox2 calcSettings = this.ultraCalcManager1.GetCalcSettings(this.textBox2); calcSettings.PropertyName = "Text"; calcSettings.Alias = "Width"; calcSettings.ErrorValue = 1; //Create a NamedReference to calulate the area. NamedReference namedReference = null; namedReference = this.ultraCalcManager1.NamedReferences.Add("Area", "[//Height] * [//Width]"); namedReference.ErrorValue = "Error"; //Everything is added, so resume this.ultraCalcManager1.ResumeCalc(); } private void ultraCalcManager1_CalculationsCompleted(object sender, System.EventArgs e) { if ( this.ultraCalcManager1.NamedReferences.Exists("Area") ) { this.textBox3.Text = this.ultraCalcManager1.NamedReferences["Area"].FormulaResult.Value.ToString(); } }