I am using the UltraValidator to validate a number of required fields on a Windows Form. I have torn the code and documentation apart looking for a method of controlling the order that the fields are validated, but I can't find anything. This results in a messagebox with errors listed in no discernable order.
Does anyone know how I can change the order of validation so it matches the order of the fields on the screen?
Thanks!
I submitted the request.
No, there is no inside way; currently it validates in the same order in which they appear in the Controls collection. If you like you can submit a feature request for this kind of support.
There are couple of other options
a) You can validate controls individually in the order you want to validate orb) you can use validation groups and then validate each group in the order you want..
With the second option the code will be lot cleaner. Hope that helps.
Steve,
Thanks for the reply! I had started investigating this possibility, but didn't want to admit that I might have to reorder the 30 or so fields on my form in order to have them validate in the correct order.
Anyone at Infragistics have any "inside information" on how I might accomplish this task in a less labor-intensive manner? If not, I guess I'll have to quit complaining and get to work...
Thanks again!
It appears that the validation order depends on the order in which the controls were created on the form. I created a sample project where I placed three numeric editor controls on the form and then added the validator control and updated the validation properties. The only way I found to change the validation order was to go into the form designer and reorder the control code so that my first control was defined first and then the second and so on. Maybe there is a better way of doing it (probably not), but at least that will get you headed in the right direction.
Here is what my form designer code looked like after I reordered the code.
' 'First ' Me.First.Location = New System.Drawing.Point(64, 52) Me.First.Name = "First" Me.First.Size = New System.Drawing.Size(100, 21) Me.First.TabIndex = 1 Me.WinValidator.GetValidationSettings(Me.First).Condition = New Infragistics.Win.OperatorCondition(Infragistics.Win.ConditionOperator.GreaterThan, "0", True, GetType(String)) Me.WinValidator.GetValidationSettings(Me.First).DataType = GetType(Integer) Me.WinValidator.GetValidationSettings(Me.First).EmptyValueCriteria = Infragistics.Win.Misc.EmptyValueCriteria.NullOrMinValue Me.WinValidator.GetValidationSettings(Me.First).IsRequired = True Me.WinValidator.GetValidationSettings(Me.First).NotificationSettings.Text = "Please enter a value for First" Me.WinValidator.GetValidationSettings(Me.First).ValidationPropertyName = "Value" ' 'Second ' Me.Second.Location = New System.Drawing.Point(64, 79) Me.Second.Name = "Second" Me.Second.Size = New System.Drawing.Size(100, 21) Me.Second.TabIndex = 0 Me.WinValidator.GetValidationSettings(Me.Second).Condition = New Infragistics.Win.OperatorCondition(Infragistics.Win.ConditionOperator.GreaterThan, "0", True, GetType(String)) Me.WinValidator.GetValidationSettings(Me.Second).DataType = GetType(Integer) Me.WinValidator.GetValidationSettings(Me.Second).EmptyValueCriteria = Infragistics.Win.Misc.EmptyValueCriteria.NullOrMinValue Me.WinValidator.GetValidationSettings(Me.Second).NotificationSettings.Text = "Please enter a value for second" Me.WinValidator.GetValidationSettings(Me.Second).ValidationPropertyName = "Value" ' 'Third ' Me.Third.Location = New System.Drawing.Point(64, 106) Me.Third.Name = "Third" Me.Third.Size = New System.Drawing.Size(100, 21) Me.Third.TabIndex = 2 Me.WinValidator.GetValidationSettings(Me.Third).Condition = New Infragistics.Win.OperatorCondition(Infragistics.Win.ConditionOperator.GreaterThan, "0", True, GetType(String)) Me.WinValidator.GetValidationSettings(Me.Third).DataType = GetType(Integer) Me.WinValidator.GetValidationSettings(Me.Third).EmptyValueCriteria = Infragistics.Win.Misc.EmptyValueCriteria.NullOrMinValue Me.WinValidator.GetValidationSettings(Me.Third).IsRequired = True Me.WinValidator.GetValidationSettings(Me.Third).NotificationSettings.Text = "Please enter a value for third" Me.WinValidator.GetValidationSettings(Me.Third).ValidationPropertyName = "Value"