WinForm Window Popup Position control

Source: Internet
Author: User

the pop-up position of the form can be specified by the property startposition, with the default values:

Manural custom, specified by the attribute location;

Centerscreen Screen Center;

Windowsdefaultbounds system default location (but size is system default form size)

WindowsDefaultLocation system default location (size specified by property size)

Centerparent Parent Form Center

If the custom form displays a location, the property startposition selects Manural and then specifies the coordinate value of the property location.

Specify the code for where the form displays:

this. StartPosition = System.Windows.Forms.FormStartPosition.Manural;
thisnewSystem.Drawing.Point(100,100);

The implementation form appears in the lower-right corner of the screen:

Often see some software in the bottom right corner of the screen pop-up message window, with the following code can be easily implemented:

 PublicForm1 () {InitializeComponent ();
  This. StartPosition = System.Windows.Forms.FormStartPosition.Manural;
//Gets the current workspace width and height (the workspace does not contain a status bar) intScreenWidth =Screen.PrimaryScreen.WorkingArea.Width; intScreenHeight =Screen.PrimaryScreen.WorkingArea.Height; //calculates the coordinate values displayed by the form and can fine-tune several pixels as needed intx = ScreenWidth- This. Width-5; inty = screenheight- This. Height-5;
This. Location =NewPoint (x, y);}

Operation Result:

Source: http://www.cnblogs.com/libaoheng/archive/2011/07/20/2112032.html

 

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.