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