Thorvason Thorvason - 1 year ago 66
C# Question

Get if any radio button in a Groupbox was checked

I have a Windows Forms application, where I have several radio buttons stored in a

. I need to enable a different
based on the selected radio button.

doesn't seem to be the
I was looking for. Is there any way to do it my way or do I have to create a handler for each


The workflow of the applikation is: a file gets selected -> the groupbox gets enabled -> a panel/ combobox, textbox gets enabled depending on the selected radiobutton

Edit Solution

Sometimes stackoverflow recommends way better than google searches...

Event handler for groupBox with radioButtons in C#

This with un-luckys answer is the solution

Answer Source

Let gbRadioButtons be the name of the GroupBox, Then you can iterate though each radioButton in that particular Groupbox and check whether it is selected or not by using the following code(include this code where you want to check):

bool isAnyRadioButtonChecked = false;
foreach (RadioButton rdo in gbRadioButtons.Controls.OfType<RadioButton>())
    if (rdo.Checked)
if (isAnyRadioButtonChecked)
  // Code here one button is checked
  // Print message no button is selected