Is there a way to set the StartPosition of a Windows Forms form using code? It seems whatever I try results in the StartPostion being the default.
Here is what I am
public DealsForm()
{
InitializeComponent();
this.StartPosition = FormStartPosition.CenterParent;
}
Try to put it before InitializeComponent(). It might be already too late after InitializeComponent (the form might be already launch and the StatPosition is set too late).
I just wrote :
public Form1()
{
InitializeComponent();
this.StartPosition = FormStartPosition.CenterScreen;
}
And:
private void button1_Click(object sender, EventArgs e)
{
Form1 f = new Form1();
f.Show();
}
In a VS project (brand new) and when I click in my form2 a button it open the form in the middle of the screen. You can do the same with Parent...