We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Validating data

I'm trying to validate a users input in a Grid. Using the CurrentCellValidating event, I'm able to validate wheter or not the data i correct. If not, I show a message-box, and started out setting the CancelEventArgs's Cancel-property to true... But then my message-box showed up twice!!?? Then I tried setting a private variable to true if there where an error and checked for this variable's value when the CurrentCellAcceptedChanges event is fired. If the private variable is true, I set the CancenEventArgs of CurrentCellAcceptedChanges to true and it almost works fine... (my message-box is only shown once) The only problem is, that after the message-box is shown and the edited cell gets focus the user can simply just hit the Enter-key og an arrow-key and then the value is validated... How can I fix this? Kenneth

4 Replies

AD Administrator Syncfusion Team April 14, 2003 01:09 PM UTC

That should be no problem to show a message box and then set e.Cancel = true. Is it just a message box you show (with MessageBox.Show) or maybe another dialog that maybe causes Validation to be triggered once again on the parent form? Are you also setting CurrentCell.ErrorMessage? Stefan

AD Administrator Syncfusion Team April 15, 2003 03:55 AM UTC

No I'm not setting any CurrentCell.ErrorMessage... Attached is some of my code. I've implemented my own version of the GridControl (EaGridControl.cs), because I'd like the user to be able to hit the Enter-key and then move from one enabled cell to the next (even if this in the next row)... Maybe there's a better way to do this? Anyway, I've also included some of the code, from the form, that uses EaControlGrid - I hope this helps!

AD Administrator Syncfusion Team April 15, 2003 08:51 AM UTC

There is a property setting that you can use to cause the grid to wrap the row and move right on Enter.
this.gridControl1.Model.Options.WrapCellBehavior = GridWrapCellBehavior.WrapRow;

this.gridControl1.EnterKeyBehavior = GridDirectionType.Right;
Attached is a sample that uses these properties and does validation in CurrentCellAcceptedChanges without the double message.

AD Administrator Syncfusion Team April 15, 2003 09:38 AM UTC

Man did I just waste a lot of time figuring that out! Great job, Clay! Thanks for the quick response!

Live Chat Icon For mobile
Up arrow icon