I have a picturebox which was created programatically and its location should be determined when the form loads.
I set the location property to a point but no matter what point is set, the picturebox appears on a fixed location when the form loads.
Below is the code:
I've checked the values of the point coordinates and they vary each time the form loads but somehow the picturebox always remain fixed at the same point on the form. I have made sure that the locked property of the control is set to false.Code:In the picture class: public PictureBox PlaceFlower() { PictureBox flower = new PictureBox(); flower.Height = 80; flower.Width = 80; flower.Image = Image.FromFile("C:\\grass.bmp"); return flower; } public Point SetCoordinates() { int x = randomClass.Next(10,50); int y = randomClass.Netxt(10,50); Point p = new Point(x, y); return p; } In the form class: private PictureBox flowerPicture; private void Form1_Load(object sender, EventArgs e) { flowerPicture = picture.PlaceFlower(); flowerPicture.Location = picture.SetCoordinates(); }
What is the problem with the picturebox location?![]()




Reply With Quote