PictureBox and images

mixsetup

Member
Joined
Oct 28, 2010
Messages
10
Programming Experience
1-3
Hi all I have a theme thing for a form and as I understand you can have only one image for a PictureBox.
now I have a panel with buttons and each button related to an image that gets loaded into the pictureBox.
Code to load is like button 8
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
Form1.PictureBox1.Image = System.Drawing.Image.FromFile("E:\pictures\parrot.png")
End Sub

now the thing is 1: I want it that if you click on the button again it will remove the image from the PictureBox.

2: If there is an image in PictureBox1 then create PictureBox2 next to PictureBox1 and put an image in PictureBox2 and 3 and so on.( Can this be done )
 
Here's an idea; use a FlowLayoutPanel and add all pictureboxes to this and also assign the image to each box (all can be done in Designer). Show/Hide the corresponding picturebox when a button is clicked, eg to toggle:
VB.NET:
pb.Visible = Not pb.Visible
 
Any way if PictureBox1 isn't displayed with a picture you can make another PictureBox say 4 auto slide to the left or auto center. So if number 1 is in the center then you click on number 2 and that will go next to it but if not it will go in the center and so on?
 
That is one of the really nice features about the FlowLayoutPanel control, it reflows the visible child controls automatically. Though it doesn't have a 'center' flow.
 
Back
Top