[Picturebox implementation] 1 foreground, many backgrounds - to show all backgrounds

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • EARNEST
    New Member
    • Feb 2010
    • 128

    [Picturebox implementation] 1 foreground, many backgrounds - to show all backgrounds

    Hello,
    I would have a window form with a groupbox that should have certain amount of images.
    I would have those images stored in a list, then my ZERO-th element would be my foreground. Elements at 1..N would be my backgrounds. Depending on the amount of elements in my list:
    a) should I insert N-1 pictureboxes and populate them with 1 foreground and appropriate background image
    b) should I somehow copy 1 picture box with the same foreground N-1 number of times and then change the background (if this is the case, any hints pls)
    c) your idea
    ---
    Thanks, EARNEST.

    Draft implementation (just messing around with code)
    Code:
                if (GraphBox.listOf_Images.Count >= 2)
                {
                    for (int i = 1; i < GraphBox.listOf_Images.Count; i++)
                    {
                        Console.WriteLine("iteration : " + i);
                        pboxFor_Images = new PictureBox();
                        pboxFor_Images.Size = new Size(img_FOREGROUND.Width, img_FOREGROUND.Height);
                        pboxFor_Images.Image = img_FOREGROUND;
                        pboxFor_Images.Location = new Point(5 + ((img_FOREGROUND.Width+5)*(i-1)), 15);
                        Image img_BACKGROUND = new Bitmap(GraphBox.listOf_Images.ElementAt(0).Width, GraphBox.listOf_Images.ElementAt(0).Height);
    
                        img_BACKGROUND = GraphBox.listOf_Images.ElementAt(i);
    
                        this.groupBox1.Controls.Add(pboxFor_Images);
                     
    
                        pboxFor_Images.Image = img_FOREGROUND;
                        pboxFor_Images.BackgroundImage = img_BACKGROUND;
                    }
                }
    any other more efficient implementations ?
Working...