Set minimum window size in C# .NET

后端 未结 4 1568
鱼传尺愫
鱼传尺愫 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:40

    You should use something like this:

    this.MinimumSize = new Size(100, 100);

    Width and Height are used to get the existing values instead of setting them.

    If you go to the definition of MinimumSize, you will see this:

    public override Size MinimumSize { get; set; }

    Once again confirming that even when you decide to set the value for it, you have to pass an actual Size instance. Width and Height are properties strictly tied to the Size instance.

提交回复
热议问题