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

Formula is not working

Clay as per your advice I started working and it looks like I am on right track I need help with following issue: I have two grid controls on my form. On the top I have a GridDataBoundGrid control and at the bottom I have GridControl. I am using following code to set the formula in bottom grid and this is where I need help. // formula int sheetfamilyID = GridFormulaEngine.CreateSheetFamilyID(); GridFormulaEngine.RegisterGridAsSheet("top", this.gridDataBoundGrid1.Model, sheetfamilyID); GridFormulaEngine.RegisterGridAsSheet("bottom", this.gridControl1.Model, sheetfamilyID); GridFormulaEngine engine = (GridFormulaCellModel)this.gridControl1.CellModels ["FormulaCell"]).Engine; engine.UsesVirtualDataSource = true; //allow formulas in any cell this.gridControl1.TableStyle.CellType = "FormulaCell"; //add sum formulas //grid 1 top grid this.gridControl1[5,1].Text = "=SUM(top!B4:top!B5)"; I have following values at top grid gridDataBoundGrid1[B4] = 10 gridDataBoundGrid1[B5] = 20 When I first run the application ‘0’ shows up as value of Formulacell at gridControl1[5,1] while it should be ‘30’. If I go in formula cell in bottom grid while application is running and edit formula to something and change it back to original then as soon as I am out of the cell correct value shows up as ‘30’. From this point on if I do any change in top grid it reflects properly in formula cell in bottom grid. Why is it not working very first time when I start the application? What is wrong with my code? Please help. Thanks

2 Replies

AD Administrator Syncfusion Team May 25, 2004 09:41 PM UTC

Do you have this code in FormLoad? If not, try moving it there. Also, try reversing the order in which you call RegisterGridAsSheet, calling this first on the bottom sheet. (The reason is that the bottom grid is really the only one with formulas in it, and it should probably be the first one registered. After switching the order, try calling engine.RecalculateRange(GridRangeInfo.Table(), true) at the bottom of FormLoad. This should force the gridControl to recalculate, and hopefully show the proper values initially. Make sure you have already loaded the data in the GridDataBoundGrid.DataSource before you call engine.Recalculaterange, otherwise teh GridControl will just use zeros for these missing values.

VI Vivek May 25, 2004 09:44 PM UTC

reversing the order Worked. Thansk clay.

Live Chat Icon For mobile
Up arrow icon