My problem is : I have 2 Panels (panel1,panel2) where panel1.Size = new Size(200, 200); and Panel2.Size = new Size(600, 600); where both panel’s have within a CustomControl which can get Dragged and change it Possition (szbControl1 ,szbControl2) .
My Question is ,how can i set szbControl2.Location properly (proportionally)based on szbControl1.Location where szbControl1 parent is panel1 and szbControl2 parent is panel2 ,like if i move the szbControl1 at bottom also szbControl2 should be at bottom.
So far i tried this :
private void sizeAbleCTR2_LocationChanged(object sender, EventArgs e)
{
int smallX = (sizeAbleCTR2.Location.X * panel1.Size.Width) / 100;
int smallY = (sizeAbleCTR2.Location.Y * panel1.Size.Height) / 100;
int largeX = (smallX * panel2.Width) / 100;
int largeY = (smallY * panel2.Height) / 100;
sizeAbleCTR1.Location = new Point(largeX,largeY);
}
like using the Percentage but it’s not working .
The code you provided does not take into account the size of the szbControls. The ratio of the (location/the differences of the sizes) should be equal.