We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

StackOverflowException with circular reference

Hello. I'm wondering what the best way is to troubleshoot a problem I'm having with the Syncfusion GridControl version 6.403.0.15.

The application we have is flexible in that it allows users to define formula's for the grid. Some cell values are loaded with data and then other cells are loaded with formula's that do something with that data.

What happens is that when the formula's are loaded into the cells, if there is a circular reference, the GridControl throws a StackOverflowException and crashes the application.

Is there a way to test the formula's or load the grid and validate it in some way so that I might catch the exception before it happens?


Here's a simple example (attached as well).

I have a Windows Form with a 6.403.0.15 Syncfusion GridControl on it. Cell A1 = 1, cell B1 = 2 and cell C1 = A1 + B1. That works. If I set cell A1 = C1, creating the circular reference, you'll see the behavior I'm referring to.


public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.Load += new EventHandler(Form1_Load);
}

void Form1_Load(object sender, EventArgs e)
{
gridControl1.SetCellInfo(1, 1, GetGridStyleInfo("=A3", "FormulaCell", typeof(string)), Syncfusion.Styles.StyleModifyType.Changes);
gridControl1.SetCellInfo(2, 1, GetGridStyleInfo(2, "Static", typeof(Double)), Syncfusion.Styles.StyleModifyType.Changes);
gridControl1.SetCellInfo(3, 1, GetGridStyleInfo("=A1+A2", "FormulaCell", typeof(string)), Syncfusion.Styles.StyleModifyType.Changes);
gridControl1.ConfirmChanges();
}

private GridStyleInfo GetGridStyleInfo(object cellValue, string cellType, Type type)
{
GridStyleInfo gridStyleInfo = new GridStyleInfo();
gridStyleInfo.CellType = cellType;
gridStyleInfo.CellValue = cellValue;
gridStyleInfo.CellValueType = type;
return gridStyleInfo;
}
}




StackOverflowExceptionExample_babaf9.zip

1 Reply

LS Lingaraj S Syncfusion Team July 28, 2009 12:17 PM UTC

Hi Rick,

Thank you for your interest in Syncfusion product.

I can able to see the issue in GridControl Formula cell, when the cross reference has been used in FormulaCell, so please try using SuspendCatchExceptions method in form load to solve this issue.

Refer the code below:

Syncfusion.Windows.Forms.ExceptionManager.SuspendCatchExceptions();
GridFormulaEngine engine = ((GridFormulaCellModel)gridControl1.CellModels["FormulaCell"]).Engine;
engine.DoCircularCheckInValidating = true;
gridControl1.SetCellInfo(1, 1, GetGridStyleInfo("=A3", "FormulaCell", typeof(string)), Syncfusion.Styles.StyleModifyType.Changes);
gridControl1.SetCellInfo(2, 1, GetGridStyleInfo(2, "Static", typeof(Double)), Syncfusion.Styles.StyleModifyType.Changes);
gridControl1.SetCellInfo(3, 1, GetGridStyleInfo("=A1+A2", "FormulaCell", typeof(string)), Syncfusion.Styles.StyleModifyType.Changes);


Please refer the below forum thread to prevent the cross reference errors in FormulaCell.
Circular-formula-crashes-the-application

Please let me know if you have any queries.

Regards,
Lingaraj S.

Loader.
Live Chat Icon For mobile
Up arrow icon