ShareThis

Sunday, August 4, 2013

[C#] WinForms - How to add your own methods to Control functions [with anonymous methods]

Adding your own methods to event handlers on controls is super easy.



Example 1
txtDataReceived.Click += delegate { foo(localVariable1,localVariable2); };
Example 2
imgbtn.Click += delegate { lbl.Visible = false; DoPostBack(); }; 

1 comments:

Post a Comment