简体   繁体   中英

Prevent winforms application resizing

I am developing a winforms application.my problem is ,i have a mdi child form called Frmaddpackage which has a size of 892 * 339.but if any i open this form while which is full screen,then i open my form Frmaddpackage,it will show as full screen.

how can i remove that,so that Frmaddpackage is always of fixed size.i have set the formborder style as fixed single.

1.This is actual screen size. 在此处输入图片说明

But if i open any of forms,and then i open my form the size is increased as. 在此处输入图片说明

一旦显示了表单,就可以尝试设置表单WindowState属性,这可能会解决问题。

Frmaddpackage.WindowState = FormWindowState.Normal;

您可以将最大表格尺寸设置为等于尺寸。

try

   this.WindowState = FormWindowState.Normal;
   this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
   this.ClientSize = new System.Drawing.Size("Set the Current Size");\
   this.MaximumSize = new System.Drawing.Size("Set the Current Size");

so that form wont get maximized ... i mean set current size as Maximum size

Add this code on InitializeComponents() or Form.Load()

this.MinimumSize = this.Size; //Minimum size is current size
this.MaximumSize = this.Size; //Maximum size is current size so window can't be smaller than current size and can't be bigger!

Optionally you can change FormBorderStyle to fixed, and if you want to disable possibility of Maximalization, use:

this.MaximalizeBox = false; //Disabling resizing may cause bugs with maximalization of window.

Sorry for my bad English, but code should work well (I use it in my applications)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM