Vertically (only) resizable windows form in C#

前端 未结 6 1539
时光取名叫无心
时光取名叫无心 2020-12-04 14:55

I have a situation where it would be beneficial to me to allow my windows form to be resized by the user, but only vertically. After some searching, it seems like there isn\

6条回答
  •  北荒
    北荒 (楼主)
    2020-12-04 15:07

    Just an idea...

    public partial class Form1 : Form {
        int _width;
    
        public Form1() {
            _width = this.Width;
            InitializeComponent();
        }
    
        protected override void OnResize(EventArgs e) {
            this.Width = _width;
            base.OnResize(e);
        }
    }
    

    EDIT: please note that the min/max size solutions work much better than this hack :)

提交回复
热议问题