pictureBox1
holds the reference to the last created one, that's the problem.
private void button2_Click(object sender, EventArgs e)
{
PictureBox pb = tabControl1.SelectedTab.Controls.OfType<picturebox>().FirstOrDefault(p => p.Name == "picturebox1name");
if (pb != null)
pb.Image = WindowsFormsApplication7.Properties.Resources.logo2;
}
Found Here -
only last dynamically created picturebox is accessible[
^]
[Edit member="Tadit"]
Link text added to reflect the article title.
Corrected formatting and grammatical issues.
[/Edit]