Есть форма. По умолчанию
$comboBox скрыт от пользователя. Нужно, чтобы при нажатии на кнопку
$radioButton1 $comboBox становился видимым. В коде я прописал:
if ($radioButton1.Checked -eq $true) {
$comboBox.Visible = $true
}
но
$comboBox не появляется. В чём причина?
Add-Type -assembly System.Windows.Forms
$listComputersForm = New-Object System.Windows.Forms.Form
$listComputersForm.Text = "Мои компьютеры"
$listComputersForm.Width = 250
$listComputersForm.Height = 380
$listComputersForm.AutoSize = $true
$groupBox1 = New-Object System.Windows.Forms.GroupBox
$groupBox1.Text = "Выбор сети"
$groupBox1.AutoSize = $true
$groupBox1.Width = 240
$groupBox1.Height = 80
$groupBox1.Location = New-Object System.Drawing.Point(5,5)
$radioButton1 = New-Object System.Windows.Forms.RadioButton
$radioButton1.Text = "Из Active Directory"
$radioButton1.Location = New-Object System.Drawing.Point(10,20)
$radioButton1.AutoSize = $true
$radioButton2 = New-Object System.Windows.Forms.RadioButton
$radioButton2.Text = "Одноранговая сеть"
$radioButton2.Location = New-Object System.Drawing.Point(10,50)
$radioButton2.AutoSize = $true
$groupBox1.Controls.Add($radioButton1)
$groupBox1.Controls.Add($radioButton2)
if ($radioButton1.Checked -eq $true) {
$comboBox.Visible = $true
}
$groupBox2 = New-Object System.Windows.Forms.GroupBox
$groupBox2.Text = "Список компьютеров"
$groupBox2.AutoSize = $true
$groupBox2.Width = 240
$groupBox2.Height = 80
$groupBox2.Location = New-Object System.Drawing.Point(5,100)
$radioButton3 = New-Object System.Windows.Forms.RadioButton
$radioButton3.Text = "Диапазон IP-адресов"
$radioButton3.Location = New-Object System.Drawing.Point(10,20)
$radioButton3.AutoSize = $true
$radioButton4 = New-Object System.Windows.Forms.RadioButton
$radioButton4.Text = "Из текстового файла"
$radioButton4.Location = New-Object System.Drawing.Point(10,50)
$radioButton4.AutoSize = $true
$groupBox2.Controls.Add($radioButton3)
$groupBox2.Controls.Add($radioButton4)
$groupBox2.Enabled = $false
$richTextBox = New-Object System.Windows.Forms.RichTextBox
$richTextBox.Text = "Для выбора списка компьютеров укажите группу безопасности Active Directory. Загрузка списка из тысяч компьютеров может занять продолжительное время."
$richTextBox.Width = 240
$richTextBox.Height = 65
$richTextBox.BorderStyle = 'None'
$richTextBox.Location = New-Object System.Drawing.Point(5,190)
$richTextBox.Enabled = $false
$comboBox = New-Object System.Windows.Forms.ComboBox
$comboBox.Text = "Группы безопасности Active Directory"
$comboBox.Width = 240
$comboBox.Location = New-Object System.Drawing.Point(5,260)
$comboBox.Visible = $false
$buttonOK = New-Object System.Windows.Forms.Button
$buttonOK.Text = "OK"
$buttonOK.Location = New-Object System.Drawing.Point(50,290)
$buttonCancel = New-Object System.Windows.Forms.Button
$buttonCancel.Text = "Отмена"
$buttonCancel.Location = New-Object System.Drawing.Point(130,290)
$listComputersForm.Controls.Add($groupBox1)
$listComputersForm.Controls.Add($groupBox2)
$listComputersForm.Controls.Add($richTextBox)
$listComputersForm.Controls.Add($comboBox)
$listComputersForm.Controls.Add($buttonOK)
$listComputersForm.Controls.Add($buttonCancel)
$listComputersForm.ShowDialog()