With Powershell I have a Windows form, dynamically generating several text boxes. I use a validation on each textbox, then use an ErrorProvider to alert if the validation fails.
This is working fine for displaying the error '!' notification. Is there a way to check how many errors are left?
My pseudo-code would say:
- On 'OK' click
- Loop though each TextBox
- Validate each TextBox
- Error if fail / Clear error if pass
- Return
- If there are no more errors, close the form
Or do I need to maintain a separate logic to see when the errors have been rectified? (The ErrorProvider check below is just a placeholder, I have no idea what to put there!)
$ButtonOK.Add_Click({
$objectList | where {$_ -is [System.Windows.Forms.TextBox] } | foreach-object {
Validate-Input $_
}
if ($ErrorProvider -eq $null) { #This is where I'm stuck
$Form.Close()
}
})