place radio buttons in group box
Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.Application]::EnableVisualStyles()
$Form = New-Object system.Windows.Forms.Form
$Form.ClientSize = New-Object System.Drawing.Point(290,206)
$Form.text = "Form"
$Form.TopMost = $false
$Groupbox1 = New-Object system.Windows.Forms.Groupbox
$Groupbox1.height = 100
$Groupbox1.width = 200
$Groupbox1.text = "Radio Group"
$Groupbox1.location = New-Object System.Drawing.Point(39,26)
$RadioButton1 = New-Object system.Windows.Forms.RadioButton
$RadioButton1.text = "0%"
$RadioButton1.AutoSize = $true
$RadioButton1.width = 104
$RadioButton1.height = 20
$RadioButton1.location = New-Object System.Drawing.Point(20,24)
$RadioButton1.Font = New-Object System.Drawing.Font('Microsoft Sans Serif',10)
$RadioButton2 = New-Object system.Windows.Forms.RadioButton
$RadioButton2.text = "50%"
$RadioButton2.AutoSize = $true
$RadioButton2.width = 104
$RadioButton2.height = 20
$RadioButton2.location = New-Object System.Drawing.Point(20,52)
$RadioButton2.Font = New-Object System.Drawing.Font('Microsoft Sans Serif',10)
$RadioButton3 = New-Object system.Windows.Forms.RadioButton
$RadioButton3.text = "100%"
$RadioButton3.AutoSize = $true
$RadioButton3.width = 104
$RadioButton3.height = 20
$RadioButton3.location = New-Object System.Drawing.Point(20,79)
$RadioButton3.Font = New-Object System.Drawing.Font('Microsoft Sans Serif',10)
$ProgressBar1 = New-Object system.Windows.Forms.ProgressBar
$ProgressBar1.width = 262
$ProgressBar1.height = 14
$ProgressBar1.value = 28
$ProgressBar1.location = New-Object System.Drawing.Point(15,160)
$Form.controls.AddRange(@($Groupbox1, $ProgressBar1))
$Groupbox1.controls.AddRange(@($RadioButton1, $RadioButton2, $RadioButton3))
$RadioButton1.Add_CheckedChanged( { radioChecked })
$RadioButton2.Add_CheckedChanged( { radioChecked })
$RadioButton3.Add_CheckedChanged( { radioChecked })
function radioChecked {
if ($RadioButton1.checked) { $ProgressBar1.value = 0 }
if ($RadioButton2.checked) { $ProgressBar1.value = 50 }
if ($RadioButton3.checked) { $ProgressBar1.value = 100 }
}
#Write your logic code here
[void]$Form.ShowDialog()
reference:
No comments:
Post a Comment