Version

Calculate Method

Calculates the specified formula and returns the value.
Syntax
'Declaration
 
Public Function Calculate( _
   ByVal formula As String _
) As Infragistics.Win.CalcEngine.UltraCalcValue
public Infragistics.Win.CalcEngine.UltraCalcValue Calculate( 
   string formula
)

Parameters

formula
Formula to calculate.

Return Value

The result of the formula.
Remarks

The Calculate method allows you to calculate a formula once without creating a NamedReference.

This method does not ensure that any dependants of the specified formula are calculated. When using a CalcFrequency of Asynchronous, you should call the ReCalc method before calling this method.

This method throws an exception if the formula has a syntax error. Any other kind of error is returned as an instance of Infragistics.Win.CalcEngine.UltraCalcValue that represents the error that occurred.

Example
Following code shows you how to calculate a formula on fly.

Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid
Imports Infragistics.Win.CalcEngine
Imports Infragistics.Win.UltraWinCalcManager

    Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click
        Dim formula As String = "average( 10, 15, 20 )"
        Dim result As UltraCalcValue = Me.UltraCalcManager1.Calculate(formula)
        If result.IsError Then
            MessageBox.Show(Me, result.ToString())
        Else
            Dim doubleVal As Double = result.ToDouble()
            MessageBox.Show(Me, doubleVal.ToString())
        End If
    End Sub
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;
using Infragistics.Win.CalcEngine;
using Infragistics.Win.UltraWinCalcManager;

		private void button1_Click(object sender, System.EventArgs e)
		{
			string formula = "average( 10, 15, 20 )";
			UltraCalcValue result = this.ultraCalcManager1.Calculate( formula );
			if ( result.IsError )
			{
				MessageBox.Show( this, result.ToString( ) );
			}
			else
			{
				double doubleVal = result.ToDouble( );
				MessageBox.Show( this, doubleVal.ToString( ) );
			}
		}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also