读书人

怎样使winform中button位于底部解决方

发布时间: 2012-03-04 11:13:34 作者: rapoo

怎样使winform中button位于底部
winform中动态增加控件,winform的长度也随之动态增加,请问怎样才能使button永久位于winform的底部?

[解决办法]
try:

Button1.Dock = DockStyle.Bottom
[解决办法]
设置anchor属性 就可解决
[解决办法]
觉得使用Anchor合适,我的代码如下:

Button btn = new Button();
btn.Text = "测试按钮 ";
btn.Location = new Point(this.ClientRectangle.Width - btn.Width, this.ClientRectangle.Height - btn.Height);
btn.Anchor = AnchorStyles.Bottom| AnchorStyles.Right;
this.Controls.Add(btn);

读书人网 >C#

热点推荐