-4
private PictureBox[] picturebox = new PictureBox[64];
private void button2_Click(object sender, EventArgs e)
{         
   int i = int.Parse(textBox1.Text);             
   picturebox[i].BackColor = Color.Green;
}

when the button click i will take a number between 1 to 64 from user and i will change the backcolor of the picturebox which is want by user.

for ex:

int i=3;
pictureBox3.BackColor=color.green;
Gergo Erdosi
  • 40,904
  • 21
  • 118
  • 94
  • 2
    What the fawk. I don't understand, and no text at all in the question. A little effort please. – Kilazur May 23 '14 at 14:50
  • Can you explain what exactly you are having problems with? are the picture box's rendering ? are you getting any errors? Is the button click event firing properly? – Scott Selby May 23 '14 at 14:50
  • 1
    It's the user's first question obivously, you can comment and help instead of just down voting – Scott Selby May 23 '14 at 14:51
  • We don't know if your PictureBox array relates to any PictureBoxes on a form. You need to show us more code. – LarsTech May 23 '14 at 14:53
  • I think BackColor need the name of the Control, for instance, pictureBox1.BackColor. You should fill your array with something because, right now, if - let me say a random number - i = 5 , you are pointing to nothing and the code will throw an error. – Emi987 May 23 '14 at 14:55
  • i want to change one picturebox backcolor which is from 64 picturebox – user3647614 May 23 '14 at 14:59

1 Answers1

0

Try something like this:

int i = 3;
string PB= "pictureBox" + i;
PictureBox pb= this.Controls.Find(PB, true).FirstOrDefault() as PictureBox;
pb.BackColor = Color.Green;

Here you can find this example!

Community
  • 1
  • 1
Emi987
  • 385
  • 1
  • 12