c# - 如何将winform调整到顶部而不是底部 [英] How to resize winform to top and not bottom c#
本文介绍了c# - 如何将winform调整到顶部而不是底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我调整 winform 的大小时,它会扩展到底部而不是顶部.如何将表单调整到顶部而不是底部?
When i'm re sizing a winform it expands to the bottom and not to top. How do I resize a form to the top instead bottom?
谢谢!
推荐答案
如果您正在谈论在运行时更改表单的大小使其向上扩展,那么您必须更改 Location() 属性以移动它向上,以及改变高度:
If you are talking about changing the size of the form at run-time so it expands upwards, then you have to change the Location() property to move it up, as well as change the Height:
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() 属性:
An alternative approach would be to modify the Bounds() property:
int ExpandUpwardsInPixels = 50;
Rectangle bnds = this.Bounds;
bnds.Offset(0, -ExpandUpwardsInPixels);
bnds.Height = bnds.Height + ExpandUpwardsInPixels;
this.Bounds = bnds;
这篇关于c# - 如何将winform调整到顶部而不是底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文