1. In C #, the from itself has a startposition property to control the centering display.
StartPosition default value is WindowsDefaultLocation, we only need to change to Centerscreen. Note the remark on MSDN:
This property should be set before the form is displayed. You can set this property before calling the Show or ShowDialog method or in the form constructor. So don't try to change this property in the Load event, it's useless
WinForm each form can be customized to the location, through the StartPosition manual property, that is, the location displacement to determine the form's starting position.
2. Change the position of the form
Display Form2 on the right side of the Form1 form
Startposition=manual
Public Partial classForm1:form { PublicForm1 () {InitializeComponent (); Test.from1= This; } Private voidButton1_Click (Objectsender, EventArgs e) {Form2 F=NewForm2 (); F.location=NewPoint ( This. Left + This. Width, This. TOP); F.show ( This); //MessageBox.Show (this,f.width+ ":" +f.height); } }
The position of the form is mainly left (we are adults, without explaining what left means) the property and the top property determine that (Width,height) determines the size of the form, and changes to the Width and left property values cause the control's right property value to change. Where the left property value is equivalent to the Point.x property of the control's Location property value. Example code:
This. left = Convert.ToInt32 (This.textBox1.Text);
This. Top = Convert.ToInt32 (This.textBox2.Text);
WinForm Form Initial Position Chapter