Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

People also ask

Is used to set the position of form at runtime view?

Remarks. 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.

What is the default value of forms start position property?

Remarks. This enumeration is used by the StartPosition property of the Form class. It represents the different start positions of the form. The default start position is WindowsDefaultLocation .

How do I change the position of a button in Visual Studio?

In Visual Studio, drag the control to the appropriate location with the mouse. Select the control and move it with the ARROW keys to position it more precisely.


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.


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


Try:

this.Location = new Point(Screen.PrimaryScreen.Bounds.X, //should be (0,0)
                          Screen.PrimaryScreen.Bounds.Y);
this.TopMost = true;
this.StartPosition = FormStartPosition.Manual;

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.