I tried this:-
public partial class Form1 : Form
{
List buttonList = new List();
public Form1()
{
for (int n = 0; n < 100; n++)
{
Button tempButt = new Button();
tempButt.Top = n*5;
tempButt.Left = n * 5;
this.Controls.Add(tempButt);
buttonList.Add(tempButt);
}
var stopwatch = new Stopwatch();
stopwatch.Start();
foreach (Button butt in buttonList)
{
butt.Click += new System.EventHandler(button1_Click);
}
stopwatch.Stop();
Console.WriteLine(stopwatch.ElapsedMilliseconds);
}
private void button1_Click(object sender, EventArgs e)
{
Console.WriteLine("Cheese");
}
}
All the buttons appear and the events seem to fire correctly, the event handler assignment is too fast to measure sensibly. Far less than a second on my machine.
Perhaps the problem lies elsewhere?