How to add event listeners in C#?
+1
A:
You should try searching, good artice; http://www.devarticles.com/c/a/C-Sharp/Creating-Custom-Delegates-and-Events-in-C-sharp/
Dustin Laine
2010-05-27 00:39:11
+3
A:
comboBoxHost.KeyDown += new System.Windows.Forms.KeyEventHandler(Fire_KeyDown);
where KeyEventHandler
is a delegate, and Fire_KeyDown
is a local method with the delegate signature.
Or using an anonymous delegate, as in:
button1.Click += delegate(System.Object o, System.EventArgs e)
{ System.Windows.Forms.MessageBox.Show("Click!"); };
Simon Chadwick
2010-05-27 00:42:44