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
If I do a ShowDialog() and pass the parent it works ... but I really don't want to show it as a Dialog.
That is correct since ShowDialog would set frm.Parent == nvShowDeals.Parent
Since you are using .Show() then frm.Parent == null thus FormStartPosition.CenterParent is ignored.
So to accomplish this function I would make the following changes:
public DealsForm()
{
InitializeComponent();
//this.StartPosition = FormStartPosition.CenterParent;
}
//DealsForm_Load Event
private void DealsForm_Load(object sender, EventArgs e)
{
this.Location = this.Owner.Location; //NEW CODE
}
And Here I would make the following changes:
private void nvShowDeals_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
DealsForm frm = new DealsForm();
frm.DataSource = this.Deals;
frm.StartPosition = FormStartPosition.Manual; //NEW CODE
frm.Show(this);
}