How to position the opening form at specific location in C# Windows Forms?

51,606

Solution 1

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

Solution 2

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.

Solution 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;
Share:
51,606
rodsarria
Author by

rodsarria

Updated on July 09, 2022

Comments

  • rodsarria
    rodsarria almost 2 years

    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?