Question

I have an array of 20 images, and 20 picturebox, I tried displaying those images in the pictureboxes and this code made it worked:

for (int x = 1; x <= ExtractedBoxes.Count(); x++)
{
    ((PictureBox)this.Controls["pictureBox" + x.ToString()]).Image = ExtractedBoxes[x - 1];
}

But when I placed all my picture box inside a groupbox or a tablelayoutpanel it doesn't show. I want them inside a groupbox or a tablelayoutpanel so it they will be organized.

Was it helpful?

Solution

Then access your Control Collection of your Actual Container.If it is GroupBox use:

groupBoxname.Controls

Instead of this.Controls.If your container is TableLayoutPanel then use tableLayoutPanelname.Controls and so on.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top