I am writing a GUI using PowerShell Studio 2017 and i have a form with several controls on it.
I am setting the BackColor attribute of each mandatory control to PaleGreen if certain conditions are not met (validation). This all works Fine.
I would like to then run a function that will then simply check a list of controls and report if any are currently set to $control.Backcolor = "PaleGreen". I am having trouble writing this funciton.
Here is what i have so far:
Code: Select all
Function validateMandatoryControlsCompleted()
{
$ControlList = @("`$textbox1",`
"`$textbox2",`
"`$textbox3",`
"`$textbox4",`
"`$combobox1",`
"`$maskedtextbox1",`
"`$listbox1",`
"`$maskedtextbox2")
foreach ($Control in $ControlList)
{
$ControlAttribute = $Control + ".BackColor"
If ($ControlAttribute = "PaleGreen")
{
Write-Host "$Control is a mandatory field"
}
Else
{
Write-Host "$Control is not required"
}
}
}
Thanks