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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

FormulCell altered via code does not reflect change

Thread ID:

Created:

Updated:

Platform:

Replies:

69070 Oct 12,2007 12:13 AM UTC Oct 12,2007 09:33 AM UTC WinForms 1
loading
Tags: GridControl
Brian R
Asked On October 12, 2007 12:13 AM UTC

Hey there,

I have a grid where the first three rows are a series of numbers. The user then selects one of these rows via coresponding radio buttons. The fourth will then be populated with the same values of the row they just picked but they can manually override these later. The fifth row contains formula cells that show the difference between the row they selected and the current value in the fourth row.

Here's an example

Row 1 4000 (user selected row)
Row 2 5000
Row 3 6000

Row 4 4000 (equals the same as selected row)

Row 5 0 (4000 - 4000 = 0)

If they then change the value of row 4 to 4500 the value of row 5 should equal 500 as 4500 - 4000 = 500.

This much works the first time through. But if the user changes their mind and selects row 2 I then set the value of row 4 to equal 5000 and set the formula of row 5 to reflect the newly selected row. Problem is that despite the formula being changed it still acts as if the old formula is in place,
5000 - 4000 = 1000. It should be 5000 - 5000 = 0.

I tried a few different things including a suggestion I found here of using the grid engine and doing a RecalculateRange but to no avail.

The formula I'm using is very simple, "=B4-B#" where # equals the index of the selected row. I change the formula in the CurrentCellChanged event.

Does anyone have any suggetions?


TIA,

Brian

Administrator [Syncfusion]
Replied On October 12, 2007 09:33 AM UTC

After setting the formula in the cell, also set the FormulaTag to null. This should force the recomputation.

Also, you may want to use the CurrentCellMoved event instead of CurrentCellChanged.

void gridControl1_CurrentCellMoved(object sender, GridCurrentCellMovedEventArgs e)
{
GridCurrentCell cc = gridControl1.CurrentCell;
if (cc.RowIndex > 0 && cc.RowIndex < 5)
{
this.gridControl1[6, 1].Text = string.Format("= A5 - A{0}", cc.RowIndex);
this.gridControl1[6, 1].FormulaTag = null;
}
}


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.

Warning Icon 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.Close Icon

;