728x90
방법 1.
protected void Form1_OnLoad(...) {
showOnMonitor(1);
}
private void showOnMonitor(int showOnMonitor)
{
Screen[] sc;
sc = Screen.AllScreens;
if (showOnMonitor >= sc.Length) {
showOnMonitor = 0;
}
this.StartPosition = FormStartPosition.Manual;
this.Location = new Point(sc[showOnMonitor].Bounds.Left, sc[showOnMonitor].Bounds.Top);
// If you intend the form to be maximized, change it to normal then maximized.
this.WindowState = FormWindowState.Normal;
this.WindowState = FormWindowState.Maximized;
}
방법 2.
[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);
}
방법 3. 센터 적용하기. (내가 코드에 적용한 방법)
var bsloc = Screen.PrimaryScreen.Bounds.Location;
var bsb = Screen.PrimaryScreen.Bounds;
Point loc = new Point(bsloc.X + bsb.Width/2 - box.Size.Width/2, bsloc.Y + bsb.Height/2 - box.Size.Height/2);
box.Location = loc;
box.StartPosition = FormStartPosition.Manual;
box.ShowDialog();
728x90
728x90