C # set the specific position when the window starts to be displayed,

Source: Internet
Author: User

C # set the specific position when the window starts to be displayed,

When I start to set the specific position of the window, I can only directly set the position to CenterScreen by setting the StartPosition in the windows attribute. This is quite convenient and can be directly centered.

However, another problem occurs later, that is, my other forms. I want to specify a specific position for the form to appear. After checking for a long time, I realized that the Manual of StartPosition was born for this!

# Region set the window position based on the screen resolution // get the display screen width int xWidth = SystemInformation. primaryMonitorSize. width; // obtain the display height int yHeight = SystemInformation. primaryMonitorSize. height; // calculate the length and Height of the login interface in the center (minus half of the length and Height of the form) login_1.Location = new Point (xWidth/2-199, yHeight/2-153); # endregion

In this case, you must first select the StartPosition In the attribute as Manual to customize the start position;

Second, you need to add Using System. Drawing to reset the position of the Drawing.

 

Related Article

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.