I have got a for loop to loop through controls in a TableLayoutPanel. In the TableLayoutPanel, there is a series of questions and the user need to tick one of the four Checkboxes to answer that question. The first question is visible, upon ticking an answer, the second question and its Checkboxes become visible. and so on till the 9th question, which ends the form.
At the end there is a Save button where the back-end code has a for loop to loop through all the checkboxes in the tablelayoutpanel to check which checkboxes are checked which are not checked.
When the loop starts running, it starts checking the Checkboxes in the second column, not from the first, not from the beginning. The first column Checkboxes are checked at the end of the loop, which is messing up the order.
Here is the for loop
foreach (Control control1 in tableLayoutPanel1.Controls.OfType<CheckBox>())
{
CheckBox checkBox = (CheckBox)control1;
String s = checkBox.Name;
//boolean value for checkbox if is checked or not
bool value = checkBox.Checked;
listValue.Add(value);
}
Why is that happening, what can be done to force the loop to start at the first column Checkboxes?
