30

The Location property in the form is set to 0,0 (Properties Window). However, the form doesn't open at the specified location. Am I missing something?

rodsarria
  • 493
  • 1
  • 6
  • 14

4 Answers4

65

You need to set StartPosition to manual to make the form set start position to the value in Location Property.

public Form1()
{
    InitializeComponent();
    this.StartPosition = FormStartPosition.Manual;
    this.Location = new Point(0, 0);
}

Intelisense Summary for FormStartPosition.Manual

FormStartPosition FormStartPosition.Manual

The position of the form is determined by the System.Windows.Forms.Control.Location property.

Community
  • 1
  • 1
  • I've been missing the piece about the manual position for an hour. Thank you :) – Dan Jul 10 '15 at 19:52
  • Is there any way to relocate a winForm after to set an initial position?, the code of this thread works, but if I hide the form, and I try to show it again but in a new position, it remains in the initial position, a workaround is creating a new form object every time, but I want to use the same object. – AngelAvila May 23 '18 at 15:53
6

By default the start position is set to be WindowsDefaultLocation which will cause the form to ignore the location you are setting. To easily have the set location enforced, change the StartPosition to Manual.

StartPosition Property Picture

nitewulf50
  • 530
  • 1
  • 4
  • 17
5

Setting the Location at 0,0 has no effect if you forget to set StartPosition to FormStartPosition.Manual

This property enables you to set the starting position of the form when it is displayed at run time. The form’s position can be specified manually by setting the Location property or use the default location specified by Windows. You can also position the form to display in the center of the screen or in the center of its parent form for forms such as multiple-document interface (MDI) child forms.

Steve
  • 213,761
  • 22
  • 232
  • 286
  • 3
    This looks like a comment, not an answer. – Metro Smurf Jan 16 '14 at 20:07
  • 2
    I would like to know why this answer is voted down while the other identical ones are upvoted. The OP is clearly settings its property from the Designer window and I think is just looking an answer using the Designer. – Steve Jan 16 '14 at 20:13
  • 1
    I did. When the answer was posted, all I saw was: "Don't forget to set StartPosition to Manual". No link or anything else. – Metro Smurf Jan 16 '14 at 20:15
  • Well @MetroSmurf of course, the answer is really short and there is not too much to add at it – Steve Jan 16 '14 at 20:17
3

Try:

this.Location = new Point(Screen.PrimaryScreen.Bounds.X, //should be (0,0)
                          Screen.PrimaryScreen.Bounds.Y);
this.TopMost = true;
this.StartPosition = FormStartPosition.Manual;
Habib
  • 219,104
  • 29
  • 407
  • 436