2

I need to display 100 images one below the other in the form.

I followed the below idea:

Added a panel to the Form and in code I added 100 picture box and assigned each picture box with the image I have.
Now the problem is I can see only 32 picture box.
Why? Any property need to be updated...?
Below is my code :

List<int> bottomlist = new List<int>();
for (int i = 0; i < 100; i++)
{
    PictureBox pic = new PictureBox();
    Image img = //I get image by some code here//
    pic.Image = img;
    pic.Size = img.Size;
    if (i == 0)
        bottomlist.Add(pic.Bottom + 8);
    else
        bottomlist.Add(pic.Bottom + bottomlist[i - 1] +8);
    if (i == 0)
        pic.Top = 8;
    else
    {
        pic.Top = bottomlist[i - 1] + 8;
    }
    pic.Left = (panel1.ClientSize.Width - pic.Width) / 2;
    panel1.Controls.Add(pic);
}
digEmAll
  • 56,430
  • 9
  • 115
  • 140
Uthistran Selvaraj.
  • 558
  • 2
  • 11
  • 29

1 Answers1

2

i took your code and ran it and got a similar problem to yours: i only saw 8 images.

then i remembered that panels need to manually define AutoScroll to true otherwise it just looks like i have less images. now i can see them all:

enter image description here

the code is same as yours, the only added is

     this.panel1.AutoScroll = true;

if you need to resize the pictures, try this article. it basically saying to do:

public static Image resizeImage(Image imgToResize, Size size)
{
   return (Image)(new Bitmap(imgToResize, size));
}

yourImage = resizeImage(yourImage, new Size(50,50));
Community
  • 1
  • 1
No Idea For Name
  • 11,411
  • 10
  • 42
  • 70