Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Need Help with Combo Box Display of Selected Value

$
0
0

I am looking for a way to display a selected value (i.e., "Peter") in a combo box upon form load with PowerShell. When the form loads, the combo box is blank. Also, I don't think my code is very efficient because I am using "foreach" and a loop counter. Here is the code I am using. All assistance is appreciated.

 

[array]$ComboBoxArray = "John", "Peter", "Paul"

.

.

.

$Loop_CNT = 0

 

foreach ($Item in $ComboBoxArray)

{

[void] $ComboBox.Items.Add($Item)

 

if ($Item -eq "Peter")

{

$ComboBox.SelectedIndex = $Loop_CNT

 

$ComboBox.Text = $Item

}

 

$Loop_CNT = $Loop_CNT + 1

} # End of foreach loop


Viewing all articles
Browse latest Browse all 6937

Trending Articles