I have code which generates buttons dynamically
Button txt = new Button();
this.Controls.Add(txt);
txt.Top = cleft * 40;
txt.Name = "txt_" + cb;
txt.Size = new Size(200, 16);
txt.Left = 150;
But I cannot think how to generate its click event.
I assume you don't mean "how to generate", but rather how to handle. Since you have a reference to your dynamic button, just add an event handler:
txt.Click += new EventHandler(eventHandlerFunction);
Or use a lambda:
txt.Click += (object sender, EventArgs e) => ...;
Delegatesyou could also google how to get at an object from the(send)objecttxt.Click += (sender, e) => {/* your code here */};