Disable resizing of a Windows Forms form

后端 未结 5 648
耶瑟儿~
耶瑟儿~ 2020-12-07 10:27

How do I turn off the user\'s ability to resize a Windows Forms form?

I\'m having it resize itself on a click.

相关标签:
5条回答
  • 2020-12-07 11:04

    Take a look at the FormBorderStyle property

    form1.FormBorderStyle = FormBorderStyle.FixedSingle;
    

    You may also want to remove the minimize and maximize buttons:

    form1.MaximizeBox = false;
    form1.MinimizeBox = false;
    
    0 讨论(0)
  • 2020-12-07 11:06

    There is far more efficient answer: just put the following instructions in the Form_Load:

    Me.MinimumSize = New Size(Width, Height)
    Me.MaximumSize = Me.MinimumSize
    
    0 讨论(0)
  • 2020-12-07 11:17

    More precisely, add the code below to the private void InitializeComponent() method of the Form class:

    this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
    
    0 讨论(0)
  • 2020-12-07 11:18

    Another way is to change properties "AutoSize" (set to True) and "AutosizeMode" (set to GrowAndShrink).

    This has the effect of the form autosizing to the elements on it and never allowing the user to change its size.

    0 讨论(0)
  • 2020-12-07 11:28
    1. First, select the form.
    2. Then, go to the properties menu.
    3. And change the property "FormBorderStyle" from sizable to Fixed3D or FixedSingle.

    0 讨论(0)
提交回复
热议问题