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

How do I change a formula in a formulaCell type?

I have a rather complex formula, that I would to be able to change "by hand" when certain conditions occur.

How can I change a formula in a GridControl? If I just reset the .Text, nothing happens

thanks.

-Paul


5 Replies

SR SubhaSheela R Syncfusion Team February 6, 2008 07:32 AM UTC

Hi Paul,

Thank you for using Syncfusion products.

You can change the formula programmatically by setting new formula to the Text property of the GridControl . I have created a sample that shows the formula in a cell programmatically. Could you please give me more details about the complex formula, so that I could provide you the exact solution? Or please send us a sample with the issue, we will analyze it and provide you the details.
Below is the code snippet:

this.gridControl2[2, 3]. Text = "=(A2+B2)";


Please refer the sample available in the link below and let me know if it helps:

http://websamples.syncfusion.com//samples/ Grid.Windows/F71548/main.htm

Regards,
Subhasheela R




PP Paul P February 6, 2008 02:31 PM UTC

this doesn't work for me.

The complexity of the formula doesn't matter, but this is basically what I do:

in form_load I do:

this.grid[3,3].CellValue = "=sheet2!a1";
this.grid[3,3].CellType = "FormulaCell";

Then I have a timer that does a callback

in the callback after 10 secongs or so I do:
this.grid[3,3].CellValue = "=sheet3!b2";
this.grid[3,3].CellType = "FormulaCell";

but the value in the grid is still the same.
to double check, I even do
this.grid[3,4].CellValue = this.grid[3,3].CellValue
this.grid[3,4].CellType = this.grid[3,3].CellType

and the cell[3,4] actually gets the NEW values, but cell[3,3] keeps the old formula.







SR SubhaSheela R Syncfusion Team February 7, 2008 07:46 AM UTC

Hi Paul,

Thank you for using Syncfusion products.

You can clear the fromula cell value in the cell using ClearCells method of GridControl before resetting the formula.
Below is the code snippet:

this.gridControl2.ClearCells(GridRangeInfo.Cell(3, 4), true);
if (timer1.Interval == 100)
{
this.gridControl2[3, 4].CellType = GridCellTypeName.FormulaCell;
this.gridControl2[3, 4].Text = "=gridControl2!B9";
}


Please refer the sample available in the link below and let me know if it helps:

http://websamples.syncfusion.com//samples/Grid.Windows/F71548FollowUp/main.htm

Regards,
Subhasheela R





PP Paul P February 7, 2008 06:16 PM UTC

Thanks, that worked



SR SubhaSheela R Syncfusion Team February 8, 2008 02:36 AM UTC

Hi Paul,

Thanks for your update.

Regards,
Subhasheela R


Loader.
Live Chat Icon For mobile
Up arrow icon