开发者

Winforms - resize a window, but only allow change of height

开发者 https://www.devze.com 2022-12-17 05:25 出处:网络
Using Win开发者_StackOverflow社区forms, is there a way to allow resize, but only to allow the window to be made taller?The ability to make it wider not only wouldn\'t be allow, but would also be pleas

Using Win开发者_StackOverflow社区forms, is there a way to allow resize, but only to allow the window to be made taller? The ability to make it wider not only wouldn't be allow, but would also be pleasing to the user.

Additionally, the ability to set a minimum height, and also be pleasing to the user?


You can set the Form.MinimumSize and Form.MaximumSize properties in say the Forrm Load event:

this.MinimumSize = new Size(400, 0);
this.MaximumSize = new Size(400, Screen.PrimaryScreen.Bounds.Height);

Or you could simply handle the Form resize event:

private void Form1_Resize(object sender, EventArgs e)
{
    this.Width = 400; 
}

The first option is probably better as it avoids the flickering on resizing.

0

精彩评论

暂无评论...
验证码 换一张
取 消