c# - How can i create a pictureBox manually to be exactly between two panels on form1? -
my form1 size 800,600 have 2 panels in form1 designer:
panel1 @ location: 0,24 size: 200,437 panel2 @ location: 584,24 size: 200,437
the result 2 panels @ each side of form. did in program when put mouse somewhere in form1 area showing picturebox create in form1 constructor:
pb = new animatedpicturebox.animatedpictureboxs(); pb.visible = false; pb.size = new size(500, 350); pb.location = new point((clientsize.width - pb.width) / 2, (clientsize.height - pb.height) / 2);
the problem new picturebox variable pb not in size fill area between 2 panels. want size of picturebox fill space between 2 panels width , height maybe leave space 5 spaces each side there border.
how can calculate picturebox size should ?
edit**
this image program working regular. on each panel on left , right added 4 pictureboxes. when move mouse cursor inside 1 of pictureboxes area showing content in larger picturebox in middle.
and how looks when put mouse cursor in 1 of pictureboxes area picturebox in middle not big enough width , height dosent make big picturebox excatly between 2 panels. big picturebox not high , not wide enough.
if want make layout stable after resizing should use dock
property panels , set anchor
picture box. that:
panel1.dock = dockstyle.left; panel2.dock = dockstyle.right; pb.anchor = anchorstyles.left | anchorstyles.right;
and in general place in center can use that:
var width = this.width - panel1.width - panel1.margin.horizontal - panel2.width - panel2.margin.horizontal; pb.size = new size(width, 300); // put needed height here pb.top = this.height/2 - pb.height/ 2; pb.left = panel2.left + panel2.width + panel2.margin.right;
Comments
Post a Comment