Specifying startup window/form location on multiple displays

前端 未结 3 520
孤独总比滥情好
孤独总比滥情好 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);
    }
    

提交回复
热议问题