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 refresh

I am using the grid control and have a formula in one cell that is acting as a Total column. I set up the cell in the following manner: Me.YearlyDataGrid(1, 1).CellType = "FormulaCell" Dim YearRange As GridRangeInfo Dim LastColumnAlpha As String LastColumnAlpha = YearRange.GetAlphaLabel(yearCount + 1) Me.YearlyDataGrid(1, 1).CellValue = "=SUM(B1:" & LastColumnAlpha & "1)" I just want this cell to show a total of all the cells to to the right but that number could potentially change every time I open the form. It seems to work for the most part except that when I open my form I call the above code then set the values for the cells to the right of this total. This is done by the following code: Dim cnt As Integer For cnt = 0 To yearCount - 1 If yearlyData(cnt) <> 0 Then Me.YearlyDataGrid(1, cnt + 2).CellValue = CStr(yearlyData(cnt)) End If Next However, the total cell will just display 0 until the user types in a value into one of the cells on the grid. The user my not want to type in values though. It should just display a total of cells as set with this second code snippet. I have tried refreshing the row and that didn''t seem to work. Any suggestions on how to get it recalc. Thanks, Jennifer

2 Replies

AD Administrator Syncfusion Team September 14, 2004 09:43 AM

In your formload (or after setting the initial values where ever you do it), try calling engine.RecalculateRange to force the calculations to be done initially. ''recalculate cell 1,1 Dim engine As GridFormulaEngine = CType(grid.CellModels("FormulaCell"), GridFormulaCellModel).Engine engine.RecalculateRange(GridRangeInfo.Cell(1,1), True)


JE jennifer September 14, 2004 11:09 AM

Thanks for your suggestion. Unfortuanately I was not able to use RecalculateRange. It was not a member of the GridFormulaEngine object. (Maybe because of my version) But your suggestion did get me far enough that I found Refresh(string) and was able to use that successfully. Thanks again. -Jennifer

Loader.
Live Chat Icon For mobile
Up arrow icon