Prevent users from resizing the window/form size

前端 未结 11 975
粉色の甜心
粉色の甜心 2020-12-01 23:28

User can change form size. I do not find a property of form that do not allow user to change form size.

相关标签:
11条回答
  • 2020-12-01 23:52

    There are a few of workarounds for this:

    1. Set maximum size property to a value you prefer. If you do not want the application window to be shrunk as well, then set a minimum size property. If you prefer the application to have the exact same size as that of design time, then set both maximum size and minimum size as size of your window. (Once you set maximum size or minimum size from the designer, you can't resize your window programmatically, unless you re-set maximum size and minimum size programmatically again)

    2. Set FormBorderStyle to FixedSingle or FixedDialog. The difference in looks wont be noticeable for untrained eyes, but one considerable difference I'd found from my experience is that, when you make it FixedSingle, you can still change the size programmatically. With FixedDialog its not possible. That's a huge advantage for FixedSingle property. (If you want to change size of your window programmatically here after going for FixedDialog, then you got to programmatically change FormBorderStyle first, which would create a slight blink effect when running the application).

    So simply go for FixedSingle. And to make sense, do the following:

    a. Set maximize box property to false.

    b. Set SizeGripStyle to Hide.

    0 讨论(0)
  • 2020-12-01 23:52

    Change the FormBorderStyle to Fixed*.

    0 讨论(0)
  • 2020-12-01 23:57

    Set the FormBorderStyle to another value like FixedSingle or FixedDialog.

    0 讨论(0)
  • 2020-12-01 23:59

    The form has MinimumSize and MaximumSize properties that you can set to control this. You might use this if you want to keep the standard form border.

    0 讨论(0)
  • 2020-12-02 00:00

    For each form, there is a Maximize Box option. Please set it to false to avoid resize. See example here:

    0 讨论(0)
  • 2020-12-02 00:01

    Set the min and max size to the same value.

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