C# 无法通过拖动边框来调整表单大小
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12287523/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can't resize the form by dragging its borders
提问by Bohn
Form's AutoSize: False. Form's AutoSizeMode: Grow and Shrink.
表单的 AutoSize: False。 表单的 AutoSizeMode: Grow 和 Shrink。
Issue: I cant resize my form by dragging its borders, I can only do that by dragging that grip thing on the bottom right side of the form.
问题:我无法通过拖动边框来调整表单的大小,我只能通过拖动表单右下角的抓握物来做到这一点。
Is there any other property on the form that I sohlud change to fix this problem?
表单上是否有任何其他属性可以更改以解决此问题?
Here is also a screen shot of the hierarchy of controls on the form...maybe setting on lower level controls on the form is causing this?
这也是窗体上控件层次结构的屏幕截图......也许在窗体上设置较低级别的控件会导致这种情况?


采纳答案by KeithS
Make sure the FormBorderStyle is set to Sizable, and that the SizeGripStyle property is set to Auto or Hide.
确保 FormBorderStyle 设置为 Sizable,并且 SizeGripStyle 属性设置为 Auto 或 Hide。
回答by dare0021
Because this is not in the answers, I'll write this here.
因为这不在答案中,所以我会写在这里。
The problem seems to be caused by the form's AutoSizeMode being on GrowAndShrink, and not GrowOnly, which is the default setting. Resetting to GrowOnly fixed the issue.
该问题似乎是由于表单的 AutoSizeMode 位于 GrowAndShrink 而不是 GrowOnly(默认设置)引起的。重置为 GrowOnly 解决了该问题。
(confirmed on MSVS2013 with .net 4.5 on Win7)
(在 MSVS2013 上确认,在 Win7 上使用 .net 4.5)
回答by Hasala Senevirathne
int height = 960;
int width = 1280;
this.ClientSize = new System.Drawing.Size(width, height);
this way you can get a fixed form size...otherwise visual studio automatically changes it
这样你就可以得到一个固定的表单大小……否则visual studio会自动改变它
回答by piatkosia
I have the same problem if maximum size was set. Please set it to 0or to bigger than now. After that you can move the border wherever you want. Change FormBorderStyleor SizeGripStylecan't help if maximum size is too small to new settings.
如果设置了最大大小,我也会遇到同样的问题。请将其设置为0或大于现在。之后,您可以将边框移动到您想要的任何位置。如果最大尺寸对于新设置来说太小,则更改 FormBorderStyle或 SizeGripStyle无能为力。
回答by shooky
Tried everything in the above (and Microsoft's forums) couldn't get it to resize. Finally just opened another instance with a form I hadn't dorked up and compared. Here's what needed set. All are mentioned above but not as a combination.
尝试了上面(和微软的论坛)中的所有内容都无法调整大小。最后刚刚打开了另一个实例,其中包含一个我没有做过和比较的表单。这是需要的设置。所有都在上面提到,但不是作为组合。
In the form's property window (or in the code).
在窗体的属性窗口中(或在代码中)。
Autosize: False = allows resizing both dimensions (True = only width adjusted).
Autosize: False = 允许调整两个维度的大小(True = 仅调整宽度)。
AutosizeMode: GrowOnly = allows both growing and shrinking.
AutosizeMode: GrowOnly = 允许增长和收缩。
FormBorderStyle: Sizeable.
FormBorderStyle:可观。
回答by Greg Campbell
I have the same problem, I can not manually change the size of form or controls in manual mode. Tried all the above, checked prior forms in the project, I could resize them.
我有同样的问题,我无法在手动模式下手动更改表单或控件的大小。尝试了以上所有方法,检查了项目中的先前表单,我可以调整它们的大小。
Then, closed VS 2010, reopened the project, and I can resize the form and controls ....
然后,关闭VS 2010,重新打开项目,我可以调整表单和控件的大小....
" Did you try the power switch ... ;)"
“你试过电源开关了吗……;)”

