C#子窗体精确定位到父窗体的某个位…

来源:互联网 发布:wkwebview调用js方法 编辑:程序博客网 时间:2024/05/17 23:37

弹出的子窗体精确定位在父窗体的某个位置,需要有目标坐标(这里将子窗体的位置设置为父窗体中一个panel的位置,需要将panel的坐标转换成屏幕坐标)

lvlv_CauseForm cf = new lvlv_CauseForm();

cf.Left = this.PointToScreen(new Point(panel2.Left,panel2.Top)).X;(这里将panel的位置装换成相对于屏幕的坐标再赋给子窗体)

cf.Top = this.PointToScreen(new Point(panel2.Left,panel2.Top)).Y;

cf.ShowDialog();

1 0