您的位置:首页 > 编程语言 > C#

C# winfrom在Panel下面动态添加空间

2012-02-01 17:19 357 查看
private void Form5_Load(object sender, EventArgs e)

{

for (int i = 0; i < 20; i++)

{

TextBox b = new TextBox();

// Button b = new Button();

b.Text = "" + i;

b.SetBounds(p.X, p.Y, 184, 50);

b.Font = new Font(b.Font.FontFamily, 25, b.Font.Style);

// b.Click += new System.EventHandler(ClickHandler);

//b.MouseEnter += new System.EventHandler(MouseEnterHandler);

// b.MouseHover += new System.EventHandler(MouseHoverHandler);

//this.Controls.Add(b);在整个窗体下添加

panel1.Controls.Add(b); //Panel下添加

p.X += 200;

if (p.X >= this.panel1.Width - 50)

{

p.X = 0;

p.Y += 100;

}

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: