Winforms - resizing a window, but only allowing resizing

Using Winforms, is there a way to allow resizing, but only to make the window taller? The ability to make it wider will not only not allow, but will also be pleasant for the user.

In addition, the ability to set a minimum height, as well as be pleasant to the user?

+4
source share
1 answer

You can set the properties Form.MinimumSize and Form.MaximumSize, for example, the Forrm Load event:

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

Or you can simply handle the form change event:

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

The first option is probably better, since it avoids flickering when resizing.

+9
source

Source: https://habr.com/ru/post/1298951/


All Articles