0
votes

I have a button on a form "Form1", when users click this button, another form "Form2" will pop up. How can I adjust Form2's location so that it is at the center of the Form1 when it pops up? I tried adjusting the location properties but it is not working.

Thanks for the help.

1
What does it mean "I tried adjusting the location properties but it is not working"? It's like asking why you PC does not power up without saying anything other, - Jamby
Is Form2 shown at all? - ispiro

1 Answers

1
votes

You need to set the StartPosition property of Form2 to CenterParent and show the form using

Form2 form2 = new Form2();
form2.ShowDialog();

If you don't want to show the form as dialog follow the confirmed answer of this question:

How do you set the StartPosition of a Windows Forms form using code?