C # reposition the widget size and position based on the screen size

Source: Internet
Author: User

Float floScreenProportion = (float) Screen. PrimaryScreen. Bounds. Width/(float) 240.0; CPublicParameters. P_RedineControlLocationAndSize (this, floScreenProportion );



/// <Summary> /// adjust the space size and position according to the screen size. FloScreenProportion is: Screen size/current design size // For example, the current design size is 240, Screen. primaryScreen. bounds. width is the actual Screen size obtained. // floScreenProportion = (float) Screen. primaryScreen. bounds. width/(float) 240.0; /// </summary> /// <param name = "parent"> </param> /// <param name = "floScreenProportion"> </param> public static void p_RedineControlLocationAndSize (Control parent, float floScreenProportion) {foreach (Control control in parent. controls) // traverses all Controls on THE Form {control. width = (int) (floScreenProportion * control. width); control. location = new Point (int) (floScreenProportion * (float) control. location. x), control. location. y); if (control. controls. count> 0) {P_RedineControlLocationAndSize (control, floScreenProportion );}}}


This article is from the "Snow volcano" blog, please be sure to keep this source http://zw20045.blog.51cto.com/1135644/1290063

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.