Hi,
I have wingrid with one updatable column which accepts the decimal value. When user edit the value, in the BeforeCellUpdate event I can check whether value is correct (like within a acceptable range etc.) or cancel the change if not. But if the value is correct I need to the round the value to max of 4 decimal points (as use can enter any number of decimal in the field, I am not using any mask control for the field and don't want to use any) I cannot change the NewValue field in the BeforeCellUpdate event as it is readonly, what is the best way to update the value once user has updated the cell and exited the edit mode before the underlying datasouce is updated.
Also the grid update mode is set to UpdateMode.OnCellChange
Thx
Have you tried simply setting the Value property of the cell?
If that doesn't work for some reason, then another option would be to do your validation in the BeforeExitEditMode event, instead of BeforeCellUpdate. Then you could examine the Text of the EditorResolved on the cell to do the validation. And if you need to change the value, you would change the Value on the editor.
Well in the BeforeCellUpdate event I cannot set the value of the cell as it throw exception "Value property can not be assigned while BeforeCellUpdate event is in progress" also setting the value of e.Cell.EditorResolved.Value is not working as grid is ignoring it. In the event BeforeExitEditMode, I do not have reference to the cell, I am getting it through ActiveCell, is this the right way?
I tried this out using the BeforeExitEditMode event and it seems to work just fine for me. Here's my code:
private void ultraGrid1_BeforeExitEditMode(object sender, Infragistics.Win.UltraWinGrid.BeforeExitEditModeEventArgs e) { UltraGrid grid = (UltraGrid)sender; UltraGridCell activeCell = grid.ActiveCell; if (activeCell != null && activeCell.Column.Key == "Decimal 1") { EmbeddableEditorBase editor = activeCell.EditorResolved; if (editor.Value != null && !(editor.Value is DBNull) && (decimal)editor.Value > 5) { editor.Value = 5; } } }