Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
145459 | Jun 23,2019 03:36 PM UTC | Jun 26,2019 09:25 AM UTC | WinForms | 2 |
![]() |
Tags: GridControl |
CalcEngine formulaEngine;
CustoCalulate calc = new CustoCalulate(this.gridControl1);
formulaEngine = new CalcEngine(calc);
public class CustoCalulate : ICalcData
{
GridControl grid;
public CustoCalulate(GridControl _grid)
{
grid = _grid;
}
public event ValueChangedEventHandler ValueChanged;
public object GetValueRowCol(int row, int col)
{
return grid[row, col].CellValue;
}
public void SetValueRowCol(object value, int row, int col)
{
grid[row, col].FormattedText = value.ToString();
}
public void WireParentObject()
{
}
} |
this.gridControl1.CurrentCellEditingComplete += GridControl1_CurrentCellEditingComplete;
this.gridControl1.CurrentCellInitializeControlText += GridControl1_CurrentCellInitializeControlText;
private void GridControl1_CurrentCellInitializeControlText(object sender,GridCurrentCellInitializeControlTextEventArgs e)
{
if(e.Style.CellType.Equals(GridCellTypeName.FormulaCell) && e.Style.Tag != null)
{
e.ControlText = e.Style.Tag.ToString();
}
}
private void GridControl1_CurrentCellEditingComplete(object sender, EventArgs e)
{
GridCurrentCell cc = this.gridControl1.CurrentCell;
GridStyleInfo style = this.gridControl1[cc.RowIndex, cc.ColIndex];
if (style != null && style.CellType.Equals(GridCellTypeName.FormulaCell))
{
//To compute the array formula
if (style.Text.StartsWith("{=") && style.Text.EndsWith("}"))
{
style.Tag= style.CellValue;
style.FormattedText = formulaEngine.ParseAndComputeFormula(style.Text);
}
}
} |
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.
This page will automatically be redirected to the sign-in page in 10 seconds.