open window form in center c# code example

Example: c# center windows form

// Do not call CenterToScreen() directly from your code. Instead,
	// Use somthing like this

	//-- After InitializeComponent()
	InitializeComponent();

	//-- Center Screen - Multi Monitor Support
	Rectangle workingArea = Screen.FromControl(this).WorkingArea;
	this.Location = new Point()
    {
      X = Math.Max(workingArea.X, workingArea.X + (workingArea.Width - this.Width) / 2),
      Y = Math.Max(workingArea.Y, workingArea.Y + (workingArea.Height - this.Height) / 2)
    };