当我调整winform的大小时,它会扩展到底部而不是顶部。 如何将表单调整到顶部而不是底部?
谢谢!
答案 0 :(得分:3)
如果您正在谈论在运行时更改表单的大小以使其向上扩展,那么您必须更改Location()属性以将其向上移动,以及更改高度:
int ExpandUpwardsInPixels = 50;
this.Location = new Point(this.Location.X, this.Location.Y - ExpandUpwardsInPixels); // move it up
this.Size = new Size(this.Size.Width, this.Size.Height + ExpandUpwardsInPixels); // increase the height
另一种方法是修改Bounds()属性:
int ExpandUpwardsInPixels = 50;
Rectangle bnds = this.Bounds;
bnds.Offset(0, -ExpandUpwardsInPixels);
bnds.Height = bnds.Height + ExpandUpwardsInPixels;
this.Bounds = bnds;