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(); }
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();
}
1.把图片读成内存图片。
2.对你第一个按钮进行深层拷贝,不要new一个出来。
那不用按钮 不知道用什么哦 listview会不会同样卡