Right, in Windows Forms, I've created a grid of 100 picture boxes. Once a picture box is clicked it will turn green, if clicked again it will turn back to the initial colour.
In order to save these I've put each picture box state into an array of bool[100]. These will be saved in XML using serialization. (true if green, false if white(default)).
When loading I am going to need to use the array of bool and define each picturebox's state. The picture box's names are pictureBox1, pictureBox2, pictureBox3 etc. Is there a convenient way of doing this?
Maybe you can understand me better like this:
for (int i = 0; i < 100; i++) {
if (pictureBoxes[i] == true) //pictureBoxes[] is the bool[] loaded
{
**pictureBox+i** .BackColor== System.Drawing.Color.LawnGreen;
}
else if (pictureBoxes[i] == false)
{
//System.Drawing.Color.White;
}
}
This example does not work; Please help?
pictureBoxControls[i].if (picturebox[i].BackColor == System.Drawing.Color.LawnGreen) {(See the answers for how to actually get the object.)