WinForm Form Initial Position Chapter

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.