Hi,
I have a validation message that appears when user edits a cell for example when user enters a -ve value and then wants to apply the change. The apply event does not happen when the validation message occurs. focus seems to be lost for the next event to occur.
Steps
Edits cell to -ve value , then he clicks a save button , control goes through the AfterCellUpdate event , a validation is checked and if value is -ve a message with OK button is popped up. User clicks OK , now the control does not go back to the save click and the change is lost. this situation happens only when the validation occurs.
Should i be using some other event to track this validation. Any suggestions and tips would be really helpful.
Thanks,
keerti
Hi Mike,
Thanks for the reply. I just moved the validation from cell update to save click to capture the validation message , solved my problem.
-Keerti
Hi Keerti,
I'm not sure I understand what you are describing. What exactly is not happening? It sounds like you are saying that code does not continue to execute after you show the MessageBox, but I don't think that's possible.
Anyway, if you are validating data in a grid cell, the After events are usually too late. You need to validate before the data is committed to the data source, not after. So I would recommend using BeforeCellUpdate or maybe even BeforeExitEditMode.
Note that in both of these events, the Value of the cell will not have been updated, yet - the Value comes from the data source. So you have to deal with the Text property of the cell.