VS2017 C# winForm 还原窗口时居中显示

在窗口的resize事件中写代码

        private void Form_Order_Content_Resize(object sender, EventArgs e)
        {
            //还原窗口时居中显示
            int screenTop = (System.Windows.Forms.Screen.GetWorkingArea(this).Width-this.Width)/2;
            int screenLeft = (System.Windows.Forms.Screen.GetWorkingArea(this).Height-this.Height)/2;
            if (this.WindowState == FormWindowState.Normal)
            {
                this.Location = new Point(screenTop, screenLeft);
            }
        }
原文地址:https://www.cnblogs.com/nb08611033/p/8820816.html