tags:

views:

18

answers:

1

I have grouped some checkbox in GroupBox1, 2, 3 respectively. Now I want to know the tag value ( I am using a TAG property to assign a some value to radio button ) of check box which is checked in either of the groupboxes.

Is there any solution besides using if then statements?

+1  A: 

Iterate over the group box components and check which ones are check boxes. Afterwards, check their Checked state, or whatever you want to do.

C# example:

foreach (Control c in groupBox1.Controls)
{
    if (c is CheckBox && ((CheckBox)c).Checked)
    {
        // whatever
    }
}
thelost
Well that one is quite obvious. Is there any one line statement to achieve this?
Shubham
Not really, see the snippet I just added (it's C#.NET code)
thelost