C#窗口隐藏/关闭/居中

当前窗口跳转另一个窗口,一般会隐藏当前窗口,再打开第二个窗口

 Form2 f2 = new Form2();
 f2.Show();
 this.Hide();

当这个窗口点击关闭或者程序执行完毕,需要结束窗体

 this.Dispose();
 this.Close();

窗体居中

Form1 mainForm = new Form1();
mainForm.StartPosition = FormStartPosition.CenterScreen;
Application.Run(mainForm);
// int xWidth = SystemInformation.PrimaryMonitorSize.Width;//获取显示器屏幕宽度
// int yHeight = SystemInformation.PrimaryMonitorSize.Height;//高度
原文地址:https://www.cnblogs.com/htwzl/p/7351794.html