Version

UltraCalcManager Class

A component for providing formula calculation functionality to controls.
Syntax
'Declaration
 
Public Class UltraCalcManager 
   Inherits Infragistics.Win.UltraComponentBase
   Implements Infragistics.Shared.IUltraComponent, Infragistics.Win.CalcEngine.IUltraCalcManager, Infragistics.Win.UltraWinCalcManager.FormulaBuilder.IFormulaBuilderInfo 
public class UltraCalcManager : Infragistics.Win.UltraComponentBase, Infragistics.Shared.IUltraComponent, Infragistics.Win.CalcEngine.IUltraCalcManager, Infragistics.Win.UltraWinCalcManager.FormulaBuilder.IFormulaBuilderInfo  
Remarks

The UltraCalcManager component creates a calculation network which can include controls (via CalcSettings and NamedReference. This allows you to set up formulas that will be calculated based on other values.

Each item in the network is called a reference. A reference can be a CalcSettings object which represent a control, a NamedReference which is essentially a constant or calulcated value with no visual representation, or an object that represent part of a control, such as an UltraGridColumn. A reference may be the target of a formula or the source value used in a formula, or both.

Example
Following code shows how to use formulas in UltraWinGrid.

Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid


    Private Sub UltraGrid1_InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles ultraGrid1.InitializeLayout
        ' A valid UltraCalcManager instance must be assigned to the the CalcManager
        ' property of the UltraGrid in order to be able to use formulas. Typically
        ' you do this by simply putting an UltraCalcManager component on the form. If
        ' you have already put an UltraCalcManager on the form then you don't need to
        ' assign the CalcManager proeprty. NOTE: You must add UltraWinCalcManager
        ' assembly to the list of assembly references.
        Dim calcManager As Infragistics.Win.UltraWinCalcManager.UltraCalcManager
        calcManager = New Infragistics.Win.UltraWinCalcManager.UltraCalcManager(Me.Container)
        e.Layout.Grid.CalcManager = calcManager

        ' You can set formula on a column.
        e.Layout.Bands(0).Columns("Col1").Formula = "10 * [Col2]"

        ' You can create a formula summary. Following summary calculates the sum of
        ' Col1 column.
        e.Layout.Bands(0).Summaries.Add("Summary1", "sum( [Col1] )")

        ' FormulaErrorAppearance specifies the appearance of cells and summaries that
        ' contain formula errors.
        e.Layout.Override.FormulaErrorAppearance.BackColor = Color.Red

        ' FormulaRowIndexSource specifies which rows to use for calculations, all
        ' rows or just the visible rows. For example, if you have a summary "sum(
        ' [Column1] )" which sums up the values of Column1, VisibleIndex specifies
        ' that the values from only the visible rows should be used for calculating
        ' the sum.
        e.Layout.Override.FormulaRowIndexSource = FormulaRowIndexSource.ListIndex
    End Sub
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;


		private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
		{
			// A valid UltraCalcManager instance must be assigned to the the CalcManager
			// property of the UltraGrid in order to be able to use formulas. Typically
			// you do this by simply putting an UltraCalcManager component on the form. If
			// you have already put an UltraCalcManager on the form then you don't need to
			// assign the CalcManager proeprty. NOTE: You must add UltraWinCalcManager
			// assembly to the list of assembly references.
			Infragistics.Win.UltraWinCalcManager.UltraCalcManager calcManager;
			calcManager = new Infragistics.Win.UltraWinCalcManager.UltraCalcManager( this.Container );
			e.Layout.Grid.CalcManager = calcManager;

			// You can set formula on a column.
			e.Layout.Bands[0].Columns["Col1"].Formula = "10 * [Col2]";

			// You can create a formula summary. Following summary calculates the sum of
			// Col1 column.
			e.Layout.Bands[0].Summaries.Add( "Summary1", "sum( [Col1] )" );

			// FormulaErrorAppearance specifies the appearance of cells and summaries that
			// contain formula errors.
			e.Layout.Override.FormulaErrorAppearance.BackColor = Color.Red;			

			// FormulaRowIndexSource specifies which rows to use for calculations, all
			// rows or just the visible rows. For example, if you have a summary "sum(
			// [Column1] )" which sums up the values of Column1, VisibleIndex specifies
			// that the values from only the visible rows should be used for calculating
			// the sum.
			e.Layout.Override.FormulaRowIndexSource = FormulaRowIndexSource.ListIndex;
		}
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