I want to have a picture album that when I click any picture it goes to another form to edit that picture.
Now I have some pictureBoxes in the form with the names like PB0, PB1, PB2,...
and a method like this
private void msgShow(int id)
{
MessageBox.Show(id.ToString());
}
when I add event handler to the two pictureBoxes like this
PB11.Click += new EventHandler((sender2, e2) => msgShow(3));
PB12.Click += new EventHandler((sender2, e2) => msgShow(4));
when I click PictureBox1 (PB1) messageBox shows
3
and when i click PictureBox2 (PB2) messageBox shows
4
it was true since I added 18 new pictureBoxes and used this code to do that
for (int i = 0; i <= 19; i++)
{
((PictureBox)Form2.ActiveForm.Controls.Find("PB" + i, true)[0]).Click += new EventHandler((sender2, e2) => msgShow(i));
}
now its wrong and when I click each pictureBox messageBox shows
20
but I want to show unique numbers for each PictureBox