hi gurus
I have a groupbox with two radio buttons on it, is there a way to check if any of the radio button is checked without having to go to individual radio control but from the Groupbox control.
Thanks a bunch
Printable View
hi gurus
I have a groupbox with two radio buttons on it, is there a way to check if any of the radio button is checked without having to go to individual radio control but from the Groupbox control.
Thanks a bunch
You can check it by default at the startup of your form.
From the actual groupbox control? I doubt. You can loop thru all controls within the groupbox checking for radio buttons which are checked.
The GroupBox should have Controls collection. If all you have in the groupbox is the two radio buttons, then there should be only two controls in the Controls collection, so you could loop through the Controls collection, casting each to a radio button (you will have to do that, since they will be controls, which don't have a Checked property), and checking their checked state. This could be done with LINQ, too, which would be pretty compact.
However, if there is anything else in the GroupBox in addition to the radiobuttons, then you will have to add in a further step to check that the type is radiobutton before casting them.
All of the previous posts compel me to ask the obvious question which is if you are only talking about two buttons, what is the issue with checking them individually?
Thanks to all a bunch
hack this time are only two radio controls but what about if I have 20 what then, so I thought maybe at the parent level I could do something.
Thanks all again