这是创建按钮的代码
public System.Windows.Forms.Button creatbtn()
{
for (int i = 0; i < 20; i++)
{
btn = new System.Windows.Forms.Button();
this.Controls.Add(btn);
btn.Top = c * 28;
btn.Left = 150;
btn.Text = "button" + this.c.ToString();
c = c + 1;
}
return btn;
}
答案 0 :(得分:0)
喜欢@Dmitry Bychenko sait 就像你为top做的一样,但是做左手
public System.Windows.Forms.Button creatbtn()
{
for (int i = 0; i < 20; i++)
{
btn = new System.Windows.Forms.Button();
this.Controls.Add(btn);
//btn.Top = c * 28
btn.Top = 28;
//btn.Left = 150
btn.Left = 150 + (c * (btn.Width + 5));
btn.Text = "button" + this.c.ToString();
c++;
}
return btn;
}