Version

FormulaCircularityError Event

Fired any time a formula attempts to reference itself either directly or indirectly.
Syntax
'Declaration
 
Public Event FormulaCircularityError As FormulaCircularityErrorEventHandler
public event FormulaCircularityErrorEventHandler FormulaCircularityError
Event Data

The event handler receives an argument of type FormulaCircularityErrorEventArgs containing data related to this event. The following FormulaCircularityErrorEventArgs properties provide information specific to this event.

PropertyDescription
Context (Inherited from Infragistics.Win.CalcEngine.FormulaErrorEventArgsBase) 
DisplayErrorMessage Gets / set whether to display an error message to the user
ErrorDisplayText (Inherited from Infragistics.Win.CalcEngine.FormulaErrorEventArgsBase) 
Remarks

FormulaCircularityError is fired any time a formula attempts to reference itself either directly or indirectly.

Circular references cannot be resolved by the UltraCalcmanager and so no calculations involving circular references will be performed.

Example
Following code demonstrates how the FormulaCircularityError event works and some of the information available on the associated event args.

For an overview of how to handle events in Visual Basic or Visual C#, see Event Handlers in Visual Basic and Visual C#. For specific information and code examples illustrating how to consume events in your application, see Consuming Events in the .NET Framework Developer's Guide.

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
        Me.UltraCalcManager1.NamedReferences.Clear()
        ' Add two formulas that refer to each other. This will cause the
        ' FormulaCircularityError event to be raised. This event will be raised only
        ' once even if there are multiple formulas that are involved in circularity.
        Me.ultraCalcManager1.NamedReferences.Add("N1", "2 * [N2]")
        Me.ultraCalcManager1.NamedReferences.Add("N2", "2 * [N1]")
    End Sub

    Private Sub UltraCalcManager1_FormulaCircularityError(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinCalcManager.FormulaCircularityErrorEventArgs) Handles ultraCalcManager1.FormulaCircularityError
        ' You can prevent the default behavior of displaying the message box by
        ' setting the DisplayErrorMessage to false.
        e.DisplayErrorMessage = False

        ' You can use the ErrorDisplayText to set the text that will be displayed 
        ' in the error message box. NOTE: We are disabling the message box by
        ' setting DisplayErrorMessage to false above so this won't have any effect.
        e.ErrorDisplayText = "Circularity Detected !"

        ' Context is the object associated with the formula that has the circularity.
        ' It could an instance of NamedReference, CalcSettings or a grid object like
        ' UltraGridColumn or SummarySettings.
        If TypeOf e.Context Is NamedReference Then
            Dim nr As NamedReference = DirectCast(e.Context, NamedReference)
            MessageBox.Show(Me, nr.Formula & " formula is involved in a circularity.")
        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)
		{
			this.ultraCalcManager1.NamedReferences.Clear( );
			// Add two formulas that refer to each other. This will cause the
			// FormulaCircularityError event to be raised. This event will be raised only
			// once even if there are multiple formulas that are involved in circularity.
			this.ultraCalcManager1.NamedReferences.Add( "N1", "2 * [N2]" );
			this.ultraCalcManager1.NamedReferences.Add( "N2", "2 * [N1]" );
		}

		private void ultraCalcManager1_FormulaCircularityError(object sender, Infragistics.Win.UltraWinCalcManager.FormulaCircularityErrorEventArgs e)
		{
			// You can prevent the default behavior of displaying the message box by
			// setting the DisplayErrorMessage to false.
			e.DisplayErrorMessage = false;

			// You can use the ErrorDisplayText to set the text that will be displayed 
			// in the error message box. NOTE: We are disabling the message box by
			// setting DisplayErrorMessage to false above so this won't have any effect.
			e.ErrorDisplayText = "Circularity Detected !";

			// Context is the object associated with the formula that has the circularity.
			// It could an instance of NamedReference, CalcSettings or a grid object like
			// UltraGridColumn or SummarySettings.
			if ( e.Context is NamedReference )
			{
				NamedReference nr = (NamedReference)e.Context;
				MessageBox.Show( this, nr.Formula + " formula is involved in a circularity." );
			}
		}
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