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
close icon

Formula in a Grid

Hi, We are trying to implement a calculator type functionality with in a databoundgrid. We have a double column and all we wanted to is too add or subtract within the cell itsself. we need not hold the formula in the cell for future refernce. example we have A = 10 in a cell we want to make A= 10+20 within the cell. we want to psot 10+20 value as it is an calculate the new value and update the cell. we are doing some accounting table and wanted to have a inplace update with + and - signs within cells. any help in resolving this matter is appreciated. Thanking all, Purnaram.K

1 Reply

AD Administrator Syncfusion Team March 3, 2005 06:47 PM UTC

So, you want to have a GridDataBoundGrid where if your user enters 10+20 in a cell, the cells shows 30 and 30 is saved into the datasource of the grid. I think the simplest way to do this is to use Essential Calculate. You can create a CalcQuick object. this.calculator = new Syncfusion.Calculate.CalcQuick(); Then handle the CurrentCellValidating event.
private void gridDataBoundGrid1_CurrentCellValidating(object sender, CancelEventArgs e)
	GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
	cc.Renderer.Control.Text = calculator.ParseAndCompute(cc.Renderer.ControlText);

Live Chat Icon For mobile
Up arrow icon