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.
Unfortunately, activation email could not send to your email. Please try again.

Set Formula for an entire column

Thread ID:

Created:

Updated:

Platform:

Replies:

63087 Jun 27,2007 07:13 PM Jun 27,2007 07:22 PM Windows Forms 1
loading
Tags: GridControl
Richard Bysouth
Asked On June 27, 2007 07:13 PM

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

haneefm [Syncfusion]
Replied On June 27, 2007 07:22 PM

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

CONFIRMATION

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.

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.

;