I have two arrays of 16 checkboxes that I want to have gradually checked when a for statement runs. It looks like this:
public void Cycle()
{
if (host == false)
{
CheckBox[] cboxes = relayRow.CheckBoxes;
}
else if (host == true)
{
CheckBox[] cboxes = relayRow2.CheckBoxes;
}
for (int i = 0; i < 16; i++)
{
cboxes[i].Checked = true;
}
}
I am getting a red line under the 'cboxes' in the for statement saying "The name 'cboxes' does not exist in the current context." If I only use one at a time, it works perfectly, so there shouldn't be a problem with my arrays. Working one at a time is as follows:
public void Cycle()
{
CheckBox[] cboxes = relayRow.CheckBoxes;
for (int i = 0; i < 16; i++)
{
cboxes[i].Checked = true;
}
}
There should also be not problem with my boolean 'host' since I have used it in other places and it works as intended. I'm just trying to switch between which array of 16 will be checked. Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire