开发者

Dissallowing resize of a window form

开发者 https://www.devze.com 2022-12-25 22:17 出处:网络
I want that the user shouldn\'t be able to resize the window form. I was abl开发者_如何转开发e to disable the maximize button but wasn\'t able to find any property to disable resizing.

I want that the user shouldn't be able to resize the window form. I was abl开发者_如何转开发e to disable the maximize button but wasn't able to find any property to disable resizing.

Any help?


You need to set the FormBorderStyle property to one of the fixed values.


Change the FormBorderStyle to FixedSingle. Also set MinimizeBox and MaximizeBox to False. Even double clicking the title will not maximize the form.


Assuming you are talking about a WinForms form, you can disable resizing by changing the FormBorderStyle property to one of the Fixed values, such as FixedSingle. There are also MaximumSize and MinimumSize properties that may be set if you want to allow some, but not total, resizing.

If you are talking about a WPF application, then you can set the ResizeMode property to NoResize, or you can set the MaxHeight, MaxWidth, MinHeight, and MinWidth properties.

As noted in the comments for the question, make sure you have a good reason to disable resizing. Most of the time, there are better alternatives that allow resizing (especially in WPF).


Set MaximumSize and MinimumSize to the current form size

  this.MaximumSize = new System.Drawing.Size(x, y);
  this.MinimumSize = new System.Drawing.Size(x, y);


Change the frame/border type to a non-resizeable type.

0

精彩评论

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