Good morning to all,
I have a created a GUI that looks like Putty. The user may choose between Serial, Telnet and SSH to connect to a host. What I am trying to do is when the user choose the Serial radio button, to disable the group box that I have to input box field for host name or IP, live. I may perform this only once. When the user clicks on Serial Radio button, the group box is disabled, but when the user click on SSH button again is not enabled and vice versa. I also tried to create an infinite loop that checks the status but with no luck.
Any ideas?
Below is the code I use:
$groupBox = New-Object System.Windows.Forms.GroupBox
$groupBox.Location = New-Object System.Drawing.Size(3,20) #location
$groupBox.size = New-Object System.Drawing.Size(220,80) #size
$groupBox.text = "Hostname or IP adress:" #labeling the box
$Form.Controls.Add($groupBox) #activate the group box
####################group box type of connection#############################
$groupBox2 = New-Object System.Windows.Forms.GroupBox
$groupBox2.Location = New-Object System.Drawing.Size(230,20) #location
$groupBox2.size = New-Object System.Drawing.Size(250,80) #size
$groupBox2.text = "Type of Connection" #labeling the box
$Form.Controls.Add($groupBox2) #activate the group box
###############Define choise for Serial#########
$Button1 = New-Object System.Windows.Forms.RadioButton
$Button1.Location = New-Object System.Drawing.Size(15,15)
$Button1.Size = New-Object System.Drawing.Size(51,20)
$Button1.Text = "Serial"
$Button1.Checked = $true
$groupBox2.Controls.Add($Button1)
###########Define Drop List for selecting COM port#########
$ListBox = New-Object System.Windows.Forms.ComboBox
$ListBox.Location = New-Object System.Drawing.Size(75,15)
$ListBox.Size = New-Object System.Drawing.Size(60,50)
$ListBox.Height = 80
$ListBox.DropDownStyle = "DropDownList"
[array]$ListBoxArray = "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8"
ForEach ($Item in $ListBoxArray) {
$ListBox.Items.Add($Item) | Out-Null #
}
$ListBox.SelectedIndex = # Select the first item by default
#$Form.Controls.Add($ListBox)
$groupBox2.Controls.Add($ListBox)
###############Define bchoise for Telnet#########
$Button2 = New-Object System.Windows.Forms.RadioButton
$Button2.Location = New-Object System.Drawing.Size(15,35)
$Button2.Size = New-Object System.Drawing.Size(54,20)
$Button2.Text = "Telnet"
$groupBox2.Controls.Add($Button2)
###############Define choise for SSH#########
$Button3 = New-Object System.Windows.Forms.RadioButton
$Button3.Location = New-Object System.Drawing.Size(15,55)
$Button3.Size = New-Object System.Drawing.Size(51,20)
$Button3.Text = "SSH"
$groupBox2.Controls.Add($Button3)