Hello,
I read on the online help that the CellDataError event is fired after the BeforeExitEditMode is fired. I also read that the CellDataError event is not fired when the BeforeExitEditMode event is cancelled.
My issue is the following:
I have a textbox cell that will validate the input with the CellDataError event, and will notify my controller class of a change in the textbox cell via the CellChange event. Whats happening is the following:
When the user types in a value, whether valid or invalid, the CellChange event fires, but the CellDataError does not. My first assumption was that the event is being canceled so I tried using the EventManager.AllEventsEnabled = true; but that does not work either.
Anyone have an idea how to use both? I need the following sequence of events: 1- if the values are not with in the specified range of the regular expression pattern, the fire the CellDataError 2- if the values are with in the range, fire the CellChange event.
Thanks!
yes it was the second case, if I delete 1 row then after that CellDataError event does not fire anymore, but I managed it on BeforeCellDeactivate event like this:
private void ultragrid1_BeforeCellDeactivate(object sender, CancelEventArgs e) { if (ultragrid1.ActiveCell.Column.Key == "PartnerName") { if (!ControlForExistingPartner(ultragrid1.ActiveCell.Value.ToString())) { MessageBox.Show(this, rm.GetString("ItemsNotExists"), rm.GetString("msgError"), MessageBoxButtons.OK, MessageBoxIcon.Error); if (ultragrid1.ActiveCell != null) { BeginInvoke(new MethodInvoker(() => { ultragrid1.ActiveCell.Activate(); ultragrid1.PerformAction(UltraGridAction.EnterEditMode); })); } e.Cancel=true; } } }
thanks for reply Mike.
Hi Ximki,
I'm not sure I follow you. Why would CellDataError fire when deleting a row? Those two events aren't really connected and there's no reason why CellDataError should ever fire while deleting a row. A cell data error in a row that's about to be deleted is irrelevant.
Unless you are saying that after you delete a row, the CellDataError event is never firing again, even for cell's that do have errors. But if that's the case, I've never heard of anything like that. I don't see any way that could possibly happen. If that's the case, my only guess is that your code is somehow unhooking the event or something.
I'm having problems with CellDataError event,I don't get why but when I delete a row on ultragrid after that CellDataError event does not fire, I saw AfterCellUpdate and other events fire but only CellDataError event does not fire.
I think the problem is that you are setting the cell's Value property, but when in edit mode, you have to set the editor's value. You can get a reference to the editor via the cell's EditorResolved property; EmbeddableEditorBase (the type returned from EditorResolved) exposes a CurrentEditText property which gives you the raw value as entered by the user, and a settable Value property to which you can assign the original value if the validation fails. In order to do that you would have to cache the cell's value in AfterEnterEditMode.
Precisely what I did as an alternative, but the I cannot restore the original value.
Ex:
cell.Value = 1000; and must be between 0 and 1000.
User enters 1001, on the CellChange, the last value I know of is 100. Similarly, on the first CellChange event, I get the default value it had as the original value, on the second, I get 1, and third 10, and lastly, I get 100.
My workaround is to validate and if still invalid, raise a custom event to my controller class that will restore the original value, which I have in my data table.