Disable windows form maximize and minimize

Asked

Viewed 7,123 times

8

I need a solution to disable the maximize and minimize buttons of a windows form. Using WPF these two attributes would solve:

WindowStartupLocation="CenterScreen"
ResizeMode="NoResize"

But now I need it to be in a windows form. Follow the image below of how it was in form in WPF.

inserir a descrição da imagem aqui

3 answers

7


Use the following properties of Form:

form1.FormBorderStyle = FormBorderStyle.FixedSingle;
form1.MaximizeBox = false;
form1.MinimizeBox = false;  

form1.FormBorderStyle = FormBorderStyle.FixedSingle; is necessary to prevent the window from being resized with the mouse by dragging the border.

6

The form has two properties that call Maximizebox and Minimizebox, just set to false:

inserir a descrição da imagem aqui

3

There are several ways to achieve this result: If you want to disable only minimize and maximize buttons, you can use the properties MaximizeBoxand MinimizeBox:

If they are of value true:

MaximizeBox e MinimizeBox em True

If they are of value false:

MaximizeBox e MinimizeBox em False

Or use the property ControlBox, when false removes all content from the header (except the title of the header):

ControlBox em false

Browser other questions tagged

You are not signed in. Login or sign up in order to post.