Hi,
I have many ultratexteditors that must match a peticuliar regular experssion, I would like the user able to navigate between this fields even if there are errors. Then the user has to Press "Lock" button to validate.
The click event must be cancelled if there are some errors in textboxes, or balidated if there are no errors.
I've tried with one textbox first:
This snippet in the form_load event :
this.ultraValidator1.SetValidationSettings(this.tutiBdrTextEditor, this.TutiBdrCondition(this.tutiBdrTextEditor));
Then this method:
public ValidationSettings TutiBdrCondition(Control control) { ValidationSettings TutiBdrSettings = this.ultraValidator1.GetValidationSettings(control); TutiBdrSettings.Condition = new OperatorCondition(ConditionOperator.Match, @"^[A-Z]*$"); TutiBdrSettings.DataType = typeof(string); TutiBdrSettings.ValidationTrigger = ValidationTrigger.Programmatic; return TutiBdrSettings; }
Then add validation event :
private void ultraValidator1_ValidationError(object sender, Infragistics.Win.Misc.ValidationErrorEventArgs e) { if (e != null) { switch (e.Control.Name) { case "tutiBdrTextEditor": e.NotificationSettings.Action = NotificationAction.Image; e.NotificationSettings.Text = "Invalid Bdr Format"; break; } } }
And finally call Validate in the Click event of my button, before the code that is supposed to be executed if there is no error
this.ultraValidator1.Validate();
Where am I mistaking ?
When you set the ValidationTrigger to 'Programmatic', nothing will be validated until you call the Validate method. You appear to be doing this, at least based on the information available here, so something else must be factoring into this. If possible, please attach a simple sample that demonstrates the problem and we will take a closer look.