110,534
社区成员
发帖
与我相关
我的任务
分享
public void BindButton()
{
this.Controls.Clear();
int x = 0, y = 0;
for (int i =0; i < 200; i++)
{
Button btn = new Button();
btn.Text = "Btn" + i.ToString();
btn.Location = new System.Drawing.Point(x, y);
x = x + btn.Width + 10;
if (x + btn.Width > this.Width)
{
x = 0;
y = y + btn.Height + 5;
}
this.Controls.Add(btn);
}
}
private void button2_Click(object sender, EventArgs e)
{
BindButton();
}