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. (Last updated on: November 16, 2018).
Close Icon
Unfortunately, activation email could not send to your email. Please try again.
Close Icon
close icon
Vote for your favorite ebook
Succinctly Readers Awards 2020
Syncfusion Feedback

Formulas validation

Thread ID:





45321 Jun 16,2006 05:06 PM UTC Jun 19,2006 11:23 PM UTC WinForms 3
Tags: GridControl
Jean-Francois Girouard
Asked On June 16, 2006 05:06 PM UTC

Hi I am using the GridControl with formulas. Is there any way to trap formula validation errors? For exemple, if I enter "=(A1*2", I get a popup saying "mismatched parentheses". I would prefer to intercept this message, display a custom error message, and take action to correct the problem, but I can''t find a way for my code to trap or handle this. A similar thing happens when the formula "==" is entered, a popup displays "Index was outside the bounds of the array". Thanks, Jean-François Girouard

Administrator [Syncfusion]
Replied On June 17, 2006 11:05 AM UTC

One way you can do this is to handle the Currentcellvalidating event, and in your handler test the new text for validity using GridFormulaEngine.IsFormulaValid. private void gridControl1_CurrentCellValidating(object sender, CancelEventArgs e) { GridCurrentCell cc = this.gridControl1.CurrentCell; GridStyleInfo style = this.gridControl1[cc.RowIndex, cc.ColIndex]; string proposedValue = cc.Renderer.ControlText; if(style.CellType == "FormulaCell" && proposedValue.StartsWith("=")) { GridFormulaEngine engine = ((GridFormulaCellModel)this.gridControl1.CellModels["FormulaCell"]).Engine; string parsedFormula = ""; string errorMessage = ""; string computedValue = ""; if(!engine.IsFormulaValid(proposedValue, out parsedFormula, out errorMessage, out computedValue)) { MessageBox.Show(string.Format("error: {0}", errorMessage)); e.Cancel = true; } } }

Jean-Francois Girouard
Replied On June 19, 2006 01:50 PM UTC

I use the version and I don''t have the method IsFormulaValid() available in the GridFormulaEngine object. Is it only available in more recent versions? Is there another way to validate the formulas with version If it matters, I''m using VB.Net. Thanks

Administrator [Syncfusion]
Replied On June 19, 2006 11:23 PM UTC

The method was added in the 4.x code base. If you upgrade to the latest release, then you will have access to it. If you want to try to do this type of validation with an earlier release, then you would have to use reflection to access internal methods that were not exposed in the earlier releases. These methods are now public in 4.x and a new IsFormulaValid method has been added to explicitly facilitate what you want to do.


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon