Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
455
Modifying ActiveCell value while in BeforeCellUpdate
posted

Hi there,

I am trying to find a good way to modify some values in the row I am working on.

The situation is as follows:

I have a grid with a startdate, enddate and duration. On doubleclicking and editting for example the startdate the BeforeCellUpdate is called when leaving the cell.

In the BeforeCellUpdate there are a few checks to see if there are overlaps, etc. and finally I want to set the cells on the selected row so I do the following:

grid.ActiveCell.Row.Cells["ColumnName"].Value = e.NewValue;

Now when editting the cell I get the following exception on this row:

InvalidOperationException

Value property can not be assigned while BeforeCellUpdate event is in progress

I have been thinking of globally setting a variable and updating the values in the AfterCellUpdate but isn't there a better way to resolve this?

Thank in advance!