标签:class The top pos HERE mon 分屏显示 from lse
参考博客:https://blog.csdn.net/kailan818/article/details/8517126
实现代码:
private void button1_Click(object sender, EventArgs e) { var frmChild = Application.OpenForms["frmChild"]; if (frmChild != null) { frmChild.Activate(); } else { frmChild frm = new frmChild(); frm.Owner = this;//申明当前窗体是子窗体 ShowOnMonitor(frm); frm.Show(); } } private void ShowOnMonitor(frmChild frm) { Screen[] sc = Screen.AllScreens; if (sc.Length > 1) { //获取当前屏幕 Screen CurrentScreen = Screen.FromControl(this); //获取当前鼠标所在的屏幕 //Screen CurrentScreen = Screen.FromPoint(new Point(Cursor.Position.X, Cursor.Position.Y)); var child = sc.Where(it => it.DeviceName != CurrentScreen.DeviceName).FirstOrDefault(); frm.StartPosition = FormStartPosition.Manual; frm.Location = new Point(child.Bounds.Left, child.Bounds.Top); } // If you intend the form to be maximized, change it to normal then maximized. frm.WindowState = FormWindowState.Normal; frm.WindowState = FormWindowState.Maximized; }
demo地址:https://gitee.com/cainiaoA/winformSplit
标签:class The top pos HERE mon 分屏显示 from lse
原文地址:https://www.cnblogs.com/shuaimeng/p/11655001.html