Hi all!
Well, this time I have a... funny problem. One that in my logic should not exist.
I'm trying a very simple thing, centering a PictureBox in the middle of my form, both horizontally and vertically.
The PictureBox is called "CP_PB_Main"
CP_PB_Main = new PictureBox();
CP_PB_Main.Height = 150;
CP_PB_Main.Width = 150;
CP_PB_Main.Left = ((ClickPic.Width / 2) - (CP_PB_Main.Width / 2));
CP_PB_Main.Top = ((ClickPic.Height / 2) - (CP_PB_Main.Height / 2));
CP_PB_Main.Image = Resource1.bird;
CP_PB_Main.SizeMode = PictureBoxSizeMode.StretchImage;
CP_PB_Main.Click += new EventHandler(CP_PB_Main_Click);
ClickPic.Controls.Add(CP_PB_Main);
Now, by my logic it should get the height of my form, which is 300 (hardcoded), divide that by 2, which comes down to 150, then get the height from the picturebox, which is 150 (hardcoded), then half that into 75, then do 150 minus 75, which equals 75. So my picturebox should be placed at 75 pixels from the top, then it should be exactly centered... However it doesn't even look close to being centered!
Am I missing something here? Am I obtaining the wrong size-property? How can this go wrong?
Any help would be greatly appreciated!
Alex