Hi.
I have a created a panel. This has autoscroll = true
At the start i added 6 pictureboxes that are 256x256 with images. I store the last picturebox location, so that i know where to put a new picturebox.
I also add a picturebox to the upper right of the panel(location(8744,8744)), so that the panel will stretch to 9000px.
Later on when i scroll around in the panel, i can push a button and add a picturebox to the panel. The problem is that when i set the location of the picturebox and add it to the panel, it comes out totally wrong, visually.
Code for adding more images.
private void addPictureBox(Point pixelCoordinates, Bitmap image)
{
PictureBox pNewImage = new PictureBox();
imagePanel.Controls.Add(pNewImage);
pNewImage.Image = image;
pNewImage.Name = "image_:" + pixelCoordinates.X + "_" + pixelCoordinates.Y;
pNewImage.Location = pixelCoordinates;
pNewImage.Size = new System.Drawing.Size(256, 256);
pNewImage.Visible = true;
pNewImage.BackColor = Color.White;
imagePanel.Update();
}
If i debug and watches the panel, it says that the new picturebox has the location i set, but visually, it's not.
I have noticed that this is what really happens: The location of the picturebox is from where i have scrolled + location.X.
Anyone got an idea how i can fix this?
Thanks in advance.