如何使用新创建的 EventHandler 发送变量?我的代码是这样的:
for (int i = 0; i < 5; i++)
{
Button buttonX = new Button();
buttonX.Location = new Point(0, 0 + offset);
buttonX.Size = new Size(310, 48);
buttonX.Click += new EventHandler(buttonClick);
}
private void buttonClick(object sender, EventArgs e)
{
MessageBox.Show();
}
我怎样才能让它像
buttonX.Click += new EventHandler(buttonClick , i);
private void buttonClick(object sender, EventArgs e, int i)
{
MessageBox.Show(i.toString());
}