Last Updated: February 25, 2016
·
1.246K
· hjwu

How to move a form to center position

Just set the form's StartPosition property to CenterScreen.

using System.Windows.Forms;  
using System;  
using System.Drawing;  
namespace WindowsFormsApplication
{  
    public partial class Form : Form  
    {  
        public Form()  
        {  
            InitializeComponent();  
            this.StartPosition = FormStartPosition.CenterScreen;  
        }  

        private void Center(Form form)  
        {  
            form.Location = new Point(
            (Screen.PrimaryScreen.Bounds.Size.Width / 2) - (form.Size.Width / 2), 
            (Screen.PrimaryScreen.Bounds.Size.Height / 2) - (form.Size.Height / 2));  
        }  

        private void button_Click(object sender, EventArgs e)  
        {  
            Center(this);  
        }  
    }  
}

Reference : Move a form to center position