Set minimum window size in C# .NET

后端 未结 4 1610
鱼传尺愫
鱼传尺愫 2020-12-05 10:07

I am having trouble setting the minimum size of my window in a C# application I am working on. I have tried this code in the form\'s constructor:

this.Minim         


        
4条回答
  •  感动是毒
    2020-12-05 10:31

    Since Size is a struct, you can't do that.
    Instead, you need to assign a new Size value to the property, like this:

    this.MinimumSize = new Size(800, 600);
    

    EDIT Your compiler is wrong; it's confusing the Size class with the Control.Size property.

    To work around this unjust error, you need to qualify the type with a namespace:

    this.MinimumSize = new System.Drawing.Size(800, 600);
    

    Or you just forgot using System.Drawing.

提交回复
热议问题