I have a GUI with a button that will open a new window. As soon as the window opens I need it to be filled with a sires of pictures that I have stored in a dictionary of (string,bitmap) with the string representing the path name. Obviously I need to iterate across the dictionary but I don't know what code to use to display the pictures. Is there anyway to make a loop that will automatically display the images in a set size.

For a good example of the output I'm looking for, think windows explorer thumbnails when browsing a folder of pictures.

I used a FlowLayoutPanel to accomplish this some time back.

        foreach (KeyValuePair<string, int> pair in dictionary) 
        {
           //Create the picturebox

            PictureBox PicBox = new PictureBox();
            PicBox.Image = Image.FromFile(pair.Key); //Filename          
            PicBox.Dock = DockStyle.Bottom;
            PicBox.SizeMode = PictureBoxSizeMode.Zoom;
            PicBox.Height = 100;
            PicBox.Width = 100;
            flowLayoutPanel1.Controls.Add(PicBox);

        }

Hope this helps

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.