Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 10 years and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Yeah, I am familiar with using the checkchanged event to manage the checkstate of radio buttons.
I was just hoping that there was a way to avoid going through each button one at a time and defining essentially the same action for each one. I thought there was a general click event for groupboxes that could use to trigger a forloop, but I didn't see it listed among the events for that object.
Yes - you can wire up the whole group in onload so you don't have to edit it manually every time things are changed.
You can also use a flow panel to dynamically add the radio buttons. Just set the flow characteristics and add a named and labeled button. It will position itself automatically. As you add the buttons set the event function or script block for each button.
With any of these methods you will need to manually set some aspect of the control group or a variable or just enumerate the children of the group if the info is used only when the from is submitted.
The blog post mentioned previously indicated that each event must also check for the 'Checked' state:
We set the same CheckChanged event for all the radio buttons and use the $this variable to access the radio button that triggered the event.
PowerShell Code
Double-click the code block to select all.
$radiobutton_CheckedChanged={
#Use the $this variable to access the calling control
#Only set the Label if this radio button is checked
if($this.Checked -eq $true)
{
#Use the Radio Button's Text to set the label
$labelSelected.Text = $this.Text
}
}
However, that does not appear to be the case as this is working just fine:
This topic is 10 years and 8 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.