Reputation: 443
In Form1 I have this code:
pb = new PictureBox();
pb.Location = new Point(this.Bounds.Width / 2,
this.Bounds.Height / 2);
pb.Size = new Size(500,500);
The form1 size is: 800x600
If I'm using this code then pb(pictureBox) will be at the center of the form and to the right bottom. I mean the 0,0 of the pb is in the center of the form . I need that the pb 0,0 will be some where that all the pb will be over the center area of the form1.
In this case the pb 0,0 is in the center of the form so I see the rest of the pb to the right and bottom.
Upvotes: 0
Views: 97
Reputation: 63317
This is what you want:
pb.Size = new Size(500,500);
pb.Location = new Point((ClientSize.Width-pb.Width)/2,
(ClientSize.Height-pb.Height)/2);
Upvotes: 2