假设我有两个相互重叠的图片框,如下所示
如何获得图片框2相对于picturebox1的位置?
先谢谢。 :):)
答案 0 :(得分:0)
转换为屏幕坐标,然后返回到客户端坐标:
Rectangle PB2Screen = pictureBox2.RectangleToScreen(pictureBox2.ClientRectangle);
Rectangle PB2RelativeToPB1 = pictureBox1.RectangleToClient(PB2Screen);
Console.WriteLine("pictureBox2 Location Relative to pictureBox1: " + PB2RelativeToPB1.Location.ToString());
Console.WriteLine("PB2RelativeToPB1: " + PB2RelativeToPB1.ToString());