'宣言 Public Delegate Sub FormulaCircularityErrorEventHandler( _ ByVal sender As Object, _ ByVal e As FormulaCircularityErrorEventArgs _ )
public delegate void FormulaCircularityErrorEventHandler( object sender, FormulaCircularityErrorEventArgs e )
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." ); } }