The controls in the window change the size of the control with the size of the form

Source: Internet
Author: User

   PublicForm1 () {InitializeComponent (); intCount = This. Controls.Count *2+2; float[] factor =New float[Count]; inti =0; Factor[i++] =Size.width; Factor[i++] =Size.Height; foreach(Control Ctrlinch  This. Controls) {Factor[i+ +] = Ctrl. Location.x/(float) Size.width; Factor[i+ +] = Ctrl. LOCATION.Y/(float) Size.Height; Ctrl. Tag=Ctrl.            Size; } Tag=factor; }        Private voidForm1_Resize (Objectsender, EventArgs e) {            float[] Scale = (float[]) Tag; inti =2; foreach(Control Ctrlinch  This. Controls) {Ctrl. Left= (int) (Size.width * scale[i++]); Ctrl. Top= (int) (Size.Height * scale[i++]); Ctrl. Width= (int) (Size.width/(float) scale[0] *((Size) Ctrl. TAG).                Width); Ctrl. Height= (int) (Size.Height/(float) scale[1] *((Size) Ctrl. TAG).                  Height); //each use is the most initial control size, guaranteed to be accurate.             }        }

The controls in the window change the size of the control with the size of the form

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.