GUI Form Using PowerShell Add Panel, Label, Edit box, Combo Box, List Box, CheckBox and More!!!

Sign in to queue

The Discussion

  • User profile image
    Leo Jensen

    Dansk er en betingelse

  • User profile image

    I am having trouble with the Dropdown box array when trying to get list of items in the text. It just gives me options 1::, 2::, or 3::. My code is below. Any assistance would be great. Thanks in advance.

    ## Email Address Label
    $emaillbldropdown = New-Object System.Windows.Forms.Label; $emaillbldropdown.Text = "Email Address:"; $emaillbldropdown.Top = 100; $emaillbldropdown.Left = 5; $emaillbldropdown.Autosize = $true
    $form.Controls.Add($emaillbldropdown) # Add to Form
    ##Email Address Input
    $emailinputdropdown = New-Object Windows.Forms.ComboBox ; $emailinputdropdown.Top = 100; $emailinputdropdown.Left = 160; $emailinputdropdown.Width = 550
    Write-Host "Getting List of @ email addresses" (Get-Date) -ForegroundColor Green
    $ArrayEmail = Get-Content -Path 'C:\Users\Administrator\Desktop\NewHireScripts\Lists\EmailAddressList.txt' #Gets list of email address for domain
    [void] $emailinputdropdown.BeginUpdate() # This tells the control to not update the display while processing (saves time)
    $i = 0 ; $iSelect = -1
    foreach ($element in $ArrayEmail) {
    [void] $emailinputdropdown.Items.Add($thisElement)
    if ($element.label -eq "")
    {$emailinputdropdown.Text = $thisElement; $iSelect = $i } # Set Default $cbImage1.Text = $i.ToString() +"::" +$element.label
    $i ++
    $emailinputdropdown.SelectedIndex = $iSelect # Set the default SelectedIndex
    [void] $emailinputdropdown.EndUpdate() # update the control with all the data that was added
    Write-Host "Finished getting list of @ email addresses" (Get-Date) -ForegroundColor Green

Add Your 2 Cents