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

OK, newbie question I know......

$
0
0

But that is what I am in PS......  So gentle with the flames.....

Trying to get a front end for a script that uses a GUI with 4 pull down menus.  I have that working after pulling ideas and info from quite a few sites.

The exception is I cannot get the menu choices into a variable I can work with....

Below is what I have so far.....  And thanks to any and all pointers.

--------------------

$PullDownMenu1 = @("Local", "Remote")
$PullDownMenu2 = @("Prod", "Supp", "Acc", "Test", "Dev")
$PullDownMenu3 = @("AIR", "BOS", "IIS", "MSG", "MQ", "TGB")
$PullDownMenu4 = @("1", "2", "3", "4", "5", "6", "7", "8", "9", "0")
$choice = ""

# Form building
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing

#Main GUI Window parameters
$Form = New-Object System.Windows.Forms.Form
$Form.Text = "Landscape Spin Up Menu"
$Form.width = 400
$Form.height = 300
$Form.StartPosition = "CenterScreen"

#Menu Section 1
$PullDownFrom = New-Object System.Windows.Forms.ComboBox
$PullDownFrom.Location = New-Object System.Drawing.Size(140,10)
$PullDownFrom.Size = New-Object System.Drawing.Size(130,30)

ForEach ($Item in $PullDownMenu1) {
    $PullDownFrom.Items.Add($Item) | out-null
}

$Form.Controls.Add($PullDownFrom)

$PullDownFromLabel = New-Object System.Windows.Forms.Label
$PullDownFromLabel.Location = New-Object System.Drawing.Size(10,10)
$PullDownFromLabel.Size = New-Object System.Drawing.Size(100,40)
$PullDownFromLabel.Text = "Select the Location ?"
$Form.Controls.Add($PullDownFromLabel)

#Menu Section 2
$PullDownTo = New-Object System.Windows.Forms.ComboBox
$PullDownTo.Location = New-Object System.Drawing.Size(140,50)
$PullDownTo.Size = New-Object System.Drawing.Size(130,30)

ForEach ($Item in $PullDownMenu2) {
    $PullDownTo.Items.Add($Item) | Out-Null
}

$Form.Controls.Add($PullDownTo)

$PullDownToLabel = new-object System.Windows.Forms.Label
$PullDownToLabel.Location = new-object System.Drawing.Size(10,50)
$PullDownToLabel.size = new-object System.Drawing.Size(100,40)
$PullDownToLabel.Text = "Select the Landscape ?"
$Form.Controls.Add($PullDownToLabel)

#Menu Section 3
$PullDownFrom = New-Object System.Windows.Forms.ComboBox
$PullDownFrom.Location = New-Object System.Drawing.Size(140,90)
$PullDownFrom.Size = New-Object System.Drawing.Size(130,30)

ForEach ($Item in $PullDownMenu3) {
    $PullDownFrom.Items.Add($Item) | Out-Null
}

$Form.Controls.Add($PullDownFrom)

$PullDownFromLabel = New-Object System.Windows.Forms.Label
$PullDownFromLabel.Location = New-Object System.Drawing.Size(10,90)
$PullDownFromLabel.Size = New-Object System.Drawing.Size(100,40)
$PullDownFromLabel.Text = "Select the Environment ?"
$Form.Controls.Add($PullDownFromLabel)

#Menu Section 4
$PullDownFrom = New-Object System.Windows.Forms.ComboBox
$PullDownFrom.Location = New-Object System.Drawing.Size(140,130)
$PullDownFrom.Size = New-Object System.Drawing.Size(130,30)

ForEach ($Item in $PullDownMenu4) {
    $PullDownFrom.Items.Add($Item) | Out-Null
}

$Form.Controls.Add($PullDownFrom)

$PullDownFromLabel = New-Object System.Windows.Forms.Label
$PullDownFromLabel.Location = New-Object System.Drawing.Size(10,130)
$PullDownFromLabel.Size = New-Object System.Drawing.Size(100,40)
$PullDownFromLabel.Text = "Select the Number ?"
$Form.Controls.Add($PullDownFromLabel)

#OK Button Section
$OKButton = new-object System.Windows.Forms.Button
$OKButton.Location = new-object System.Drawing.Size(100,170)
$OKButton.Size = new-object System.Drawing.Size(100,20)
$OKButton.Text = "OK"
$OKButton.Add_Click({
 $Form.DialogResult = "OK"
 $Form.close()
})
$form.Controls.Add($OKButton)

#Exit Button Section
$ExitButton = New-Object System.Windows.Forms.Button
$ExitButton.Location = New-Object System.Drawing.Size(100,210)
$ExitButton.Size = New-Object System.Drawing.Size(100,20)
$ExitButton.Text = "Exit"
$ExitButton.Add_Click({
 $Form.DialogResult = "Exit"
 $Form.close()
})
$Form.Controls.Add($ExitButton)
$Form.Add_Shown({$Form.Activate()})
$Form.ShowDialog()

 

 

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles