Class GridCellFormulaModel
This GridCellModel supports entering formulas in a grid cell. This support is provided through the Engine member of this class. Engine is a GridFormulaEngine.
Inheritance
Implements
Inherited Members
Namespace: Syncfusion.Windows.Controls.Grid
Assembly: Syncfusion.Grid.Wpf.dll
Syntax
public class GridCellFormulaModel : GridCellTextBoxModel, IDisposable
Remarks
The default behavior is that any cell whose CellType is GridCellFormulaModel will be interpreted as a formula cell provided the text in the cell starts with '='. So, for such cells you would enter formulas such as =A1+A2+A3 or =Sum(A1:A3), an an attempt would be made to parse and compute the entry.
Alternatively, you can use the Syncfusion.Windows.Controls.Grid.GridCellFormulaModel.formulaChar character to specify which cells of CellType GridCellFormulaModel are to be used as formulas. You set this formulaChar private property through the class constructor which passes this parameter. If you set this value to '\0', every cell of CellType GridCellFormulaModel will be treated as a formula.
The RefreshCells(Int32, Int32) method redraws all the formula cells that depend upon a particular cell. This method is called when the user changes a value that affects other formula cells.
The GetFormattedText(GridStyleInfo, Object, Int32) method is where the actual calculations are done, if necessary, through calls to the Engine methods. This method also conditionally parses the formula only if it has been modified since the previous parse.
Constructors
GridCellFormulaModel(GridModel)
Initializes a new GridCellFormulaModel object.
Declaration
public GridCellFormulaModel(GridModel grid)
Parameters
Type | Name | Description |
---|---|---|
GridModel | grid |
Fields
ACC
Declaration
public double ACC
Field Value
Type |
---|
System.Double |
Properties
CalculatingSuspended
Gets or sets whether calculations should be done as values change in the underlying GridControl.
Declaration
public bool CalculatingSuspended { get; set; }
Property Value
Type |
---|
System.Boolean |
Engine
Gets the GridFormulaEngine associated with the CellModel. GridFormulaEngine encapsulates all formula features. Use this object to add / remove library functions.
Declaration
public GridFormulaEngine Engine { get; }
Property Value
Type |
---|
GridFormulaEngine |
FormulaChar
Gets or sets the formula character.
Declaration
public char FormulaChar { get; set; }
Property Value
Type |
---|
System.Char |
Remarks
Set this field to a particular character such as '=' to conditionally flag a cell whose CellType is GridCellFormulaModel as holding a formula. If you do not set this field, then all cells of CellType GridCellFormulaModel that begin with '=' will be treated as a formula.
Grid
Gets the GridModel associated with this cell model.
Declaration
public GridModel Grid { get; }
Property Value
Type |
---|
GridModel |
Methods
CreateRenderer()
Creates formula cell renderer.
Declaration
public override IGridCellRenderer CreateRenderer()
Returns
Type | Description |
---|---|
IGridCellRenderer | The cell renderer that this method creates. |
Overrides
Dispose(Boolean)
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing |
Overrides
GetFormattedText(GridStyleInfo, Object, Int32)
Triggers the parsing and computing of formulas.
Declaration
public override string GetFormattedText(GridStyleInfo style, object value, int textInfo)
Parameters
Type | Name | Description |
---|---|---|
GridStyleInfo | style | The GridStyleInfo object that holds cell information. |
System.Object | value | The value to format. |
System.Int32 | textInfo | textInfo is a hint who is calling, default is GridCellBaseTextInfo.DisplayText. |
Returns
Type | Description |
---|---|
System.String | Either the computed value or the raw formula text. |
Overrides
Remarks
Overridden to trigger the parsing and computing of formulas. The computed value is returned for non-editing cells. The raw formula text is returned when the cell is actively beng edited.
IsEmpty(String)
Returns whether the input string is null or has zero length.
Declaration
public static bool IsEmpty(string s)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | The input string. |
Returns
Type | Description |
---|---|
System.Boolean | True if null or zero length, false otherwise. |
RefreshCells(Int32, Int32)
This method forces any formula cell dependent upon the passed-in cell in the row and column to be recomputed. This method is called by the model whenever the contents of the passed-in cell is changed. For example, the user changing a single non-formula cell may require the recomputing of several additional formula cells. This method triggers the redrawing of these dependent cells.
Declaration
public void RefreshCells(int row, int col)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | row | Row index of the cell that was modifed by the user. |
System.Int32 | col | Column index of the cell that was modified by the user. |