Visual Studio不停地调整表单大小,请不要告诉它,帮助! [重复]

时间:2021-08-03 22:53:58

This question already has an answer here:

这个问题在这里已有答案:

I am running visual studio 2008. Every so often when I go to the designer view of one of my forms, the designer will make the form slightly larger. This happens on forms where I have a minimum size. I want the form to be the minimum size so why does it keep adjusting the size on me?

我正在运行visual studio 2008.每当我去设计师查看我的一个表单时,设计师都会使表单略大一些。这种情况发生在我有最小尺寸的表格上。我希望表单是最小的大小,为什么它会不断调整我的大小?

3 个解决方案

#1


I was having this issue with a particular form that hosted a user control. Everytime I did a full Rebuild Solution it would make the form shorter. Found a simple solution: in the designer, set the minimum size property of the form to be the same as the size property. Now when the designer messes around trying to change the size it will end up as the minimum size - which is the size you actually want.

我遇到了一个托管用户控件的特定表单的问题。每次我做一个完整的重建解决方案,它会缩短形式。找到一个简单的解决方案:在设计器中,将表单的最小大小属性设置为与size属性相同。现在,当设计师在试图改变尺寸时会感到困惑,它最终会成为最小尺寸 - 这就是你真正想要的尺寸。

#2


Have you checked AutoSizeMode on the form? Is the form inherited from a base form?

你在表单上检查了AutoSizeMode吗?表单是从基本表单继承的吗?

#3


This solution might not be ideal, but I've had problems with the designer taking on a life of its own and this worked for me.

这个解决方案可能不太理想,但我遇到了设计师自己的生活问题,这对我有用。

Subscribe to your forms Resize event either in the designer or constructor, and in the function call this.Size = this.MinimumSize.

在设计器或构造函数中订阅表单Resize事件,并在函数中调用this.Size = this.MinimumSize。

This will have an effect on the way the designer behaves too, VS must precompile some events for the designer or something.

这将对设计师的行为方式产生影响,VS必须为设计师或其他事件预编译一些事件。

#1


I was having this issue with a particular form that hosted a user control. Everytime I did a full Rebuild Solution it would make the form shorter. Found a simple solution: in the designer, set the minimum size property of the form to be the same as the size property. Now when the designer messes around trying to change the size it will end up as the minimum size - which is the size you actually want.

我遇到了一个托管用户控件的特定表单的问题。每次我做一个完整的重建解决方案,它会缩短形式。找到一个简单的解决方案:在设计器中,将表单的最小大小属性设置为与size属性相同。现在,当设计师在试图改变尺寸时会感到困惑,它最终会成为最小尺寸 - 这就是你真正想要的尺寸。

#2


Have you checked AutoSizeMode on the form? Is the form inherited from a base form?

你在表单上检查了AutoSizeMode吗?表单是从基本表单继承的吗?

#3


This solution might not be ideal, but I've had problems with the designer taking on a life of its own and this worked for me.

这个解决方案可能不太理想,但我遇到了设计师自己的生活问题,这对我有用。

Subscribe to your forms Resize event either in the designer or constructor, and in the function call this.Size = this.MinimumSize.

在设计器或构造函数中订阅表单Resize事件,并在函数中调用this.Size = this.MinimumSize。

This will have an effect on the way the designer behaves too, VS must precompile some events for the designer or something.

这将对设计师的行为方式产生影响,VS必须为设计师或其他事件预编译一些事件。