参考:https://www.cnblogs.com/crwy/p/9285463.html
//
// 摘要:
// 将指定屏幕点的位置计算成工作区坐标。
//
// 参数:
// p:
// 要转换的屏幕坐标 System.Drawing.Point。
//
// 返回结果:
// 一个 System.Drawing.Point,它表示转换后的 System.Drawing.Point、p(以工作区坐标表示)。
[TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
public Point PointToClient(Point p);
//
// 摘要:
// 将指定工作区点的位置计算成屏幕坐标。
//
// 参数:
// p:
// 要转换的工作区坐标 System.Drawing.Point。
//
// 返回结果:
// 一个 System.Drawing.Point,它表示转换后的 System.Drawing.Point、p(以屏幕坐标表示)。
public Point PointToScreen(Point p);
将一个Panel对齐到一个控件的下方,无论是单个窗体还是嵌套窗体:
private void button2_Click(object sender, EventArgs e)
{
Control ctrl = (Control)sender;
Point p1 = ctrl.PointToScreen(new Point(0, 0));
Point p2 = this.PointToScreen(new Point(0, 0));
this.Controls.Add(panel1);
panel1.Location = new Point(p1.X - p2.X, p1.Y - p2.Y + ctrl.Height);
panel1.BringToFront();
}