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

Get bad index when NamedRange has been removed

In sample code "$\Program Files\Syncfusion\Essential Suite\\Windows\Grid.Windows\Samples\Quick Start\NamedRangesForFormula", by right click and "Edit Inputs" I added Medical key and value 200. Then I used it in Cashflow sheet "=Medical". It came nicely as 200. Now, I want to remove Medical from NamedRange. Again I am using context menu and "Edit Inputs". I got bad index in cell. It is obvious that Medical is in use and I shouldn''t be able to remove it. Is there any event that I can catch this? The worse case is if I used "=Medical + 2" and then I remove Medical I got unhandled exception in SyncfusionGrid.Windows.dll for invalid char in front of +. Basically I want to do error checking and avoid improper deleting. I am using Syncfusion

2 Replies

AD Administrator Syncfusion Team August 12, 2005 05:00 PM UTC

I do not have a good suggestion for handling this problem. Our Calculate library actually has a property that tells the engine to rethrow parsing error so you can catch them if you want. But I am not sure even whether adding that property to the GridFormulaEngine would allow you to catch this particular error or not. We will have to research this to see what might be possible. You can actually catch this behavior in SaveCellInfo if you want. The idea is that anytime a formulacell is saved whith an error, you catch it. Here is a snippet that worked for me in that sample you mentioned. Due to the errors being raised, this event is actually hit more than once, so you may have ot add code to make sure you only do something one time.
private bool CheckIfError(string s)
	foreach(string s1 in this.engine.FormulaErrorStrings)
		if(s1 == s)
			return true;
	return false;
private void gridCashFlow_SaveCellInfo(object sender, GridSaveCellInfoEventArgs e)
	if(e.Style.CellType == "FormulaCell" 
		&& e.Style.Text.Length > 1
		&& e.Style.Text[0] == ''=''
		&& CheckIfError(e.Style.FormattedText))
		MessageBox.Show(string.Format("error {0},{1}  {2}", e.RowIndex, e.ColIndex, e.Style.FormattedText));

MA mayilsamy June 21, 2007 06:32 AM UTC

hai ,

how to increase the height and width in Syncfusion grid tell the syntax.

Live Chat Icon For mobile
Up arrow icon