SaveCellFormattedText event fired twice?

I have implemented handlers for QueryCellFormattedText and SaveCellFormattedText in order to allow percentage field handling (where user types ''5'' and this is treates as 5%). However, I notice that my handler receives two SaveCellFormattedText events for every cell change. Is this normal? My implementation of the handler is: String userValue = null; if(evt.Text[evt.Text.Length-1] == ''%'') { userValue = evt.Text.Substring(0, evt.Text.Length - 1); evt.Handled = true; } else { userValue = evt.Text; } double d; if (double.TryParse(userValue, System.Globalization.NumberStyles.Any, null, out d)) { userValue = "" + (d / 100d); evt.Handled = true; } if (evt.Handled) { evt.Style.Text = userValue; }

2 Replies

AD Administrator Syncfusion Team October 8, 2004 08:58 PM UTC

I see SaveCellFormattedText being raised twice as well. The first time happens as the grid tries to validate the cell contents. The second time occurs later jast as the grid is trying to save the value to the grid. I am not sure whether this is by design or not. I will have to forward it to Stefan to see if this is what he had in mind.


AD Administrator Syncfusion Team October 8, 2004 09:06 PM UTC

This is by design. The cell renderer class internally calls style.FormattedText = ControlText to determine the underlying cell value for the display text. This happens before the CurrentCellValidate event is raised and ensures the ControlValue for the renderer is up to date. Stefan

Loader.
Up arrow icon