是否有可能设置的最大宽度为形式,但留下的最大高度无限制? [英] Is it possible to set the Maximum Width for a Form but leave the Maximum Height Unrestricted?

查看:329
本文介绍了是否有可能设置的最大宽度为形式,但留下的最大高度无限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于某种原因,如果同时设置宽度和Form.MaximumSize的高度为零它会让你有一个无限制的窗口大小,但是如果你想设置你必须这样做对宽度和高度的限制与此同时。我希望有一个固定的宽度,但高度上没有任何限制。

  //无极限
this.MaximumSize =新的大小( 0,0);

//表格高度将在0
INT ArbitraryWidth = 200卡住;
this.MaximumSize =新的大小(ArbitraryWidth,0);


解决方案

使用INT_MAX,因为这是一个可以代表的理论极限由尺寸反正:

  //最大宽度200,高度不限
this.MaximumSize =新的大小(200,int.MaxValue);


For some reason if you set both of the width and the height of Form.MaximumSize to zero it will let you have an unrestricted window size, however if you want to set a limit you have to do it for both width and height at the same time. I want a fixed width but no limit on height.

    // No Limits
    this.MaximumSize = new Size(0,0);

    // Form Height will be stuck at 0
    int ArbitraryWidth = 200;
    this.MaximumSize = new Size(ArbitraryWidth, 0);

解决方案

Use INT_MAX since that's the theoretical limit that can be represented by a Size anyway:

//Max width 200, unlimited height
this.MaximumSize = new Size(200, int.MaxValue);

这篇关于是否有可能设置的最大宽度为形式,但留下的最大高度无限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆