Reputation: 22339
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?
Upvotes: 0
Views: 4257
Reputation: 6694
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
}
}
VB.NET example :
For Each c As Control In groupBox1.Controls
If TypeOf c Is CheckBox AndAlso DirectCast(c, CheckBox).Checked Then
' Whatever
End If
Next
Upvotes: 2