This would be my solution, try to see if it works for you:
private class checkedBox
{
public string name;
public bool status;
}
List<checkedBox> listChekedBox;
public void findCheckedBox(GroupBox group)
{
listChekedBox = new List<checkedBox>();
foreach (Control control in group.Controls)
{
if (control.GetType() == typeof(CheckBox))
{
checkedBox box = new checkedBox();
box.name = control.Name;
box.status = ((CheckBox)control).Checked;
listChekedBox.Add(box);
}
}
}
If you want it exactly as you indicate it, you should only change the variable type to whole:
private class checkedBox
{
public string name;
public int status;
}
List<checkedBox> listChekedBox;
public void findCheckedBox(GroupBox group)
{
listChekedBox = new List<checkedBox>();
foreach (Control control in group.Controls)
{
if (control.GetType() == typeof(CheckBox))
{
checkedBox box = new checkedBox();
box.name = control.Name;
box.status = ((CheckBox)control).Checked ? 1 : 0;
listChekedBox.Add(box);
}
}
}