Can somebody post the sequence of how events are fired on Ultrawingrid at both the rows and cell level. I am trying highlight the value in a cell, whenever user tries to edit the value in that cell. I am not able to highlight it and also once the key is pressed control exits the cell.
Thank you
Hi,
There's no way we could post a specific sequence of events. There are too many factors involved in determining which events fire and in what order. Under what particular circumstances are you interested in? And what, exactly, are you trying to achieve?
Hello Mike,
I am trying to edit a cell that has 0.00 value in it by default, If the user enters a value greater than 100.00 they should be prompted with an error message that the cell cannot accept a value greater than 100, at the same time it should be highlighted and the value should be defaulted to 0.00.
In my case when I enter 490, it prompts me with the error message and the value is not highlighted and cell has 49.00 as the value in it instead of 0.00 value in it.
I am trying to do this before the cell is updated i.e in beforecellupdate event, I have attached sample code, please take a look and let me know where I can fix this.
Thank you so much!
Hello...can anyone please take a look at the code and let me know of any ways to highlight the cell and default its value to 0.00 if an invalid value is entered by end user.
So let me just make sure I am clear on what you want to happen.
If I type 490 (or any invalid value) into the cell and try to leave:
1) The cell's value revert to the default (0.00)
2) Focus remains in the cell (the user cannot leave)
3) All of the text in the cell is highlighted.
Is that right? That's a little odd that you want to both keep focus in the cell and also revert to the original value. Are you sure you want to do both? Typically, the point of keeping focus in the cell is to allow the user to correct their entry, assuming it's a typo, and losing the value they typed in can be counterproductive.
If that's what you want, then I recommend using the BeforeExitEditMode event:
private void UltraGrid1_BeforeExitEditMode(object sender, Infragistics.Win.UltraWinGrid.BeforeExitEditModeEventArgs e) { UltraGrid grid = (UltraGrid)sender; if (null == grid.ActiveCell) return; if (grid.ActiveCell.Column.Key == "PAY") { decimal cellValue; bool success = decimal.TryParse(grid.ActiveCell.Text, out cellValue); if (success && cellValue > Convert.ToDecimal(grdPay.ActiveCell.Row.Cells["Balance"].Value) { MessageBox.Show("The entered amount can not be greater than the Balance."); e.Cancel = true; grid.ActiveCell.EditorResolved.Value = "0.00"; grid.ActiveCell.EditorResolved.SelectAll(); } } }
Thank you so much for the reply, in the code you posted where you are trying to get the latest value of cell is always returning the value as 0.
This line : bool success = decimal.TryParse(grid.ActiveCell.Text, out cellValue);
Is there any way to get the right value instead of 0.
the value in the success flag is always false as it is not able to get the edited value in cell, any ideas appreciated
Text returns the actual edited Text that is in the cell. So the only way it would return false is if the user types something into the cell that cannot be parsed into a valid decimal value. I assumed you were using decimal because that's what your code sample was doing.
What's the ActiveCell.Text in this case? Did you type something into the cell?