Set Formula for an entire column

Hi
If I want a column to use the same formula for all rows, adjusted by row number, what is the most efficient way to do this?
For example
B1 =A1 * 10
B2 =A2 * 10
...

I am using the following code at present but wondered whether there is a better way? Maybe using relative refs?

With Me.GridControl1
.ColStyles(2).CellType = "FormulaCell"

Dim engine As GridFormulaEngine = CType(.CellModels("FormulaCell"), GridFormulaCellModel).Engine

For rowIndex As Integer = .Rows.HeaderCount To .RowCount - 1
Me.GridControl1(rowIndex + 1, 2).CellValue = engine.AdjustReferences("=A1 * 10", rowIndex, 0)
Next

End With

thanks

Richard

1 Reply

HA haneefm Syncfusion Team June 27, 2007 11:22 PM UTC

Hi Richard,

You can handle the QueryCellInfo event and set the cellvalue of the formulcell there .Below are the code snippet

if e.ColIndex == 2 AND e.RowIndex > 0 Then
Dim engine As GridFormulaEngine = CType(e.Style.CellModel, GridFormulaCellModel).Engine
e.Style.CellValue = engine.AdjustReferences("=A1 * 10", e.RowIndex -1 , 0)
EndIf

Best regards,
Haneef

Loader.
Up arrow icon