C # change the form size

Source: Internet
Author: User

To change the size of the Form in C #, you only need to add a statusstrip and change sizinggrip to true. In this way, the mouse displays a resize handle in the lower right corner of the form, you can adjust the size.

The form size can be adjusted, but the control will not be adjusted together. You need to add a resize event for the form, and then adjust the widget size in the event. The following describes a listview control named listfiles:

This. listfiles. width = This. Width-
This. listfiles. Margin. horizontal;
This. listfiles. Height =
This. statusmain. Location. Y-This. listfiles. Location. Y-
This. listfiles. Margin. bottom;

Listfiles uses the toolbar and the status bar. Therefore, you do not need to adjust the start position of listfiles. You only need to adjust the size of listfiles. Its width is the width of the form minus the horizontal space occupied by listfiles. Its height is the starting position of the status bar minus the starting position of the status bar and then the size of the white space at the bottom of the listfiles.

 

In this way, the widget size can also be adjusted. But there is another problem: Sometimes we do not want the form to be dragged very small, and the basic controls are not displayed, so we need to set the minimum size of the form. BelowCodeSet the minimum size of the form to 1/3 of the workspace.

This. minimumsize = new size (systeminformation. workingarea. width/3, systeminformation. workingarea. Height/3 );

 

Author: xugd, 2009.9.23

 

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.