Specifying startup window/form location on multiple displays

前端 未结 3 512
孤独总比滥情好
孤独总比滥情好 2021-01-20 22:18

I have two displays (two monitors) connected to my machine, and I noticed a strange thing happening today. I had an Explorer window open with my compiled exe on my primary d

相关标签:
3条回答
  • 2021-01-20 22:41

    This should do the trick:

    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
    
        Form1 f = new Form1();
        f.StartPosition = FormStartPosition.Manual;
        f.Location = Screen.PrimaryScreen.Bounds.Location;
    
        Application.Run(f);
    }
    
    0 讨论(0)
  • 2021-01-20 22:47
    Screen[] myScreen = Screen.AllScreens;
    this.Location = myScreen[0].WorkingArea.Location; // Primary Screen
    this.Location = myScreen[1].WorkingArea.Location; // Secondary Screen
    
    0 讨论(0)
  • 2021-01-20 22:49

    Take a look at this: Show form on primary or secondary screen

    0 讨论(0)
提交回复
热议问题