WinForm------窗体初始化位置的显示

在窗体的构造方法里面添加

public Form2()
{
  InitializeComponent();

   //指定窗口初始化时的位置(计算机屏幕中间)
   this.StartPosition = FormStartPosition.CenterScreen;

 

   //指定窗口初始化时的位置,如果为Manual,位置由Location决定(计算机屏幕中间,如果不/2,则计算机右下角)
   this.StartPosition = FormStartPosition.Manual;
    this.Location = new Point((Screen.PrimaryScreen.WorkingArea.Width - this.Width)/2, (Screen.PrimaryScreen.WorkingArea.Height - this.Height)/2)

}

 

posted @ 2016-07-29 10:30  玉天恒  阅读(1053)  评论(0)    收藏  举报