I want to create a new form on the same location. When I call this code a new form opens but on a different screen position.
private void BtnAddForm_Click(object sender, EventArgs e)
{
Form2 form2 = new Form2();
form2.Tag = this;
form2.Location = this.Location;
form2.Show(this);
Hide();
}
I used this.Location
to get the location from my first form but this has no effect.
You need to set StartPosition
property to Manual
for this to work.
private void BtnAddForm_Click(object sender, EventArgs e)
{
Form2 form2 = new Form2();
form2.Tag = this;
form2.StartPosition = FormStartPosition.Manual;
form2.Location = this.Location;
form2.Show(this);
Hide();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With