Minimum Form Size

I have a C # form with a significant border. I would like to set the minimum size (850, 760) (the initial default size), but when I try to set the value in the form's properties menu, it changes it to (850, 720). I tried to install it by code as follows:

this.minimumSize = new System.Drawing.Size(850, 760); 

but when I run the code, I can still compress my shape vertically. Anyone have any ideas on what might be the problem?

EDIT: I use two monitors, one standard 1280x1024 and another widescreen 1366x768, maybe this is a problem? In this case, is there a way to check the resolution of the user monitor and set a minimum size based on this?

+4
source share
3 answers

Most of the code that is executed at runtime is active at design time. This gives the Winforms designer a very nice WYSIWYG user interface, but it has some bad side effects. Including a breakdown of the designer and giving you a white Darn screen. Or crash VS to the desktop if you disable this website name.

This is one of these side effects, the runtime code limits the minimum dimension of Screen.WorkingArea and does so during development. Just try entering (0, 3000) to see what happens. You can force it to assign a property in code.

+2
source

I think you should look at your code again. It should look like in the designer or in the page_load of your form.

  /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Text = "Form1"; this.MinimumSize = new Size(300,300); } 
+2
source

Try the following:

Set the FormBorderStyle property of the FixedSingle form. Then the border frame size will be disabled.

+1
source

All Articles