Hello everyone
I have started the proces of creating a GUI for a powershell script that I developed.
I will be using some radio buttons to determine what the action will be performed.
I however don’t know on how to connect a function to the selection of a specific radiobutton
As an example
#
# radiobutton 1
#
$RadioButton1 = New-Object Windows.Forms.radiobutton
$RadioButton1.text = "Vaste Tekst"
$RadioButton1.height = 20
$RadioButton1.width = 100
$RadioButton1.top = 45
$RadioButton1.left = 200
#
# radiobutton2
#
$radiobutton2 = New-Object Windows.Forms.radiobutton
$RadioButton2.text = "Vrije Tekst"
$RadioButton2.height = 20
$RadioButton2.width = 100
$RadioButton2.top = 45
$RadioButton2.left = 300
#
#When user selects radiobutton1, a textlabel should appear where additional info can be added, which on its turn then calls another function
#I thought following piece of code in the main body would do the trick, but apparently it doesn't
$event = {if ($RadioButton1.Checked) {
$Lbl_Tekst = New-Object System.Windows.Forms.Label
$Lbl_Tekst.Location = New-Object System.Drawing.Size(10, 350)
$Lbl_Tekst.AutoSize = $True
$Lbl_Tekst.Text = "versturen?"
$Form.Controls.Add($Lbl_Tekst)
}
}
$RadioButton1.add_click($event)
Can anyone help me out?
Tks + b rgds