小编loo*_*kie的帖子

按钮数组:更改属性

我有一系列按钮,如下所示:

int x = 0, y = 0;
butt2 = new Button[100];

for (int i = 0; i < 100; i++)
{
    butt2[i] = new Button();
    int names = i;
    butt2[i].Name = "b2" + names.ToString();
    butt2[i].Location = new Point(525 + (x * 31), 70 + (y * 21));
    butt2[i].Visible = true;
    butt2[i].Size = new Size(30, 20);
    butt2[i].Click += new EventHandler(butt2_2_Click); //problem lies here (1)
    this.Controls.Add(butt2[i]);
}

private void butt2_2_Click(object sender, EventArgs e)
{
    // want code here
}
Run Code Online (Sandbox Code Playgroud)

我想在点击时更改按钮的背面颜色.我想通过i …

c# winforms

2
推荐指数
1
解决办法
284
查看次数

标签 统计

c# ×1

winforms ×1