Answer the question
In order to leave comments, you need to log in
How to organize a cycle of dynamically formed elements?
How to organize a cycle of disabling comboboxes from dynamically formed combobox name elements?
function ClearOuList($count)
{
#$comboboxOuNext1.DataSource = $null
switch ($count) {
1 {
$comboboxOuNext1.visible = $false
$comboboxOuNext2.visible = $false
$comboboxOuNext3.visible = $false
$comboboxOuNext4.visible = $false
$comboboxOuNext5.visible = $false
$comboboxOuNext6.visible = $false
$comboboxOuNext7.visible = $false
$comboboxOuNext8.visible = $false
$comboboxOuNext9.visible = $false
$comboboxOuNext10.visible = $false
}
2 {
$comboboxOuNext2.visible = $false
$comboboxOuNext3.visible = $false
$comboboxOuNext4.visible = $false
$comboboxOuNext5.visible = $false
$comboboxOuNext6.visible = $false
$comboboxOuNext7.visible = $false
$comboboxOuNext8.visible = $false
$comboboxOuNext9.visible = $false
$comboboxOuNext10.visible = $false
}
3 {
$comboboxOuNext3.visible = $false
$comboboxOuNext4.visible = $false
$comboboxOuNext5.visible = $false
$comboboxOuNext6.visible = $false
$comboboxOuNext7.visible = $false
$comboboxOuNext8.visible = $false
$comboboxOuNext9.visible = $false
$comboboxOuNext10.visible = $false
}
4 {
$comboboxOuNext4.visible = $false
$comboboxOuNext5.visible = $false
$comboboxOuNext6.visible = $false
$comboboxOuNext7.visible = $false
$comboboxOuNext8.visible = $false
$comboboxOuNext9.visible = $false
$comboboxOuNext10.visible = $false
}
5 {
$comboboxOuNext5.visible = $false
$comboboxOuNext6.visible = $false
$comboboxOuNext7.visible = $false
$comboboxOuNext8.visible = $false
$comboboxOuNext9.visible = $false
$comboboxOuNext10.visible = $false
}
6 {
$comboboxOuNext6.visible = $false
$comboboxOuNext7.visible = $false
$comboboxOuNext8.visible = $false
$comboboxOuNext9.visible = $false
$comboboxOuNext10.visible = $false
}
7 {
$comboboxOuNext7.visible = $false
$comboboxOuNext8.visible = $false
$comboboxOuNext9.visible = $false
$comboboxOuNext10.visible = $false
}
8 {
$comboboxOuNext8.visible = $false
$comboboxOuNext9.visible = $false
$comboboxOuNext10.visible = $false
}
9 {
$comboboxOuNext9.visible = $false
$comboboxOuNext10.visible = $false
}
10 {
$comboboxOuNext10.visible = $false
}
}
Answer the question
In order to leave comments, you need to log in
Try like this:
function ClearOuList($count)
{
#$comboboxOuNext1.DataSource = $null
switch ($count) {
1 {
Get-Variable -Name "comboboxOuNext[1-9]" | %{$_.Value.visible=$false
Get-Variable -Name "comboboxOuNext10" | %{$_.Value.visible=$false
}
2 {
Get-Variable -Name "comboboxOuNext[2-9]" | %{$_.Value.visible=$false
Get-Variable -Name "comboboxOuNext10" | %{$_.Value.visible=$false
}
3 {
Get-Variable -Name "comboboxOuNext[3-9]" | %{$_.Value.visible=$false
Get-Variable -Name "comboboxOuNext10" | %{$_.Value.visible=$false
}
4 {
Get-Variable -Name "comboboxOuNext[4-9]" | %{$_.Value.visible=$false
Get-Variable -Name "comboboxOuNext10" | %{$_.Value.visible=$false
}
5{
Get-Variable -Name "comboboxOuNext[5-9]" | %{$_.Value.visible=$false
Get-Variable -Name "comboboxOuNext10" | %{$_.Value.visible=$false
}
6{
Get-Variable -Name "comboboxOuNext[6-9]" | %{$_.Value.visible=$false
Get-Variable -Name "comboboxOuNext10" | %{$_.Value.visible=$false
}
7 {
Get-Variable -Name "comboboxOuNext[7-9]" | %{$_.Value.visible=$false
Get-Variable -Name "comboboxOuNext10" | %{$_.Value.visible=$false
}
8 {
Get-Variable -Name "comboboxOuNext[89]" | %{$_.Value.visible=$false
Get-Variable -Name "comboboxOuNext10" | %{$_.Value.visible=$false
}
9 {
Get-Variable -Name "comboboxOuNext9" | %{$_.Value.visible=$false
Get-Variable -Name "comboboxOuNext10" | %{$_.Value.visible=$false
}
10 {
Get-Variable -Name "comboboxOuNext10" | %{$_.Value.visible=$false
}
}
}
} Get-Variable * | ? {$_.name -match "comboboxOuNext[0-9]{1,2}"}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question