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.
Unfortunately, activation email could not send to your email. Please try again.

StackOverflowException with circular reference

Thread ID:

Created:

Updated:

Platform:

Replies:

88502 Jul 27,2009 11:46 AM Jul 28,2009 08:17 AM Windows Forms 1
loading
Tags: GridControl
Rick Glos
Asked On July 27, 2009 11:46 AM

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

Lingaraj S [Syncfusion]
Replied On July 28, 2009 08:17 AM

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.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;