How make one event handler that applies to multiple controls in C#? -
in visual basic knew how it, i'm new c#, can guys tell me how make "private void" mouse hover applies same event multiple controls? there's example:
private void button1, button2, button3, button4_mousehover(object sender, eventargs e) { btn.image = pic }
just declare 1 event handler , point each button @ it:
private void common_mousehover(object sender, eventargs e) { button btn = sender button; if (btn != null) btn.image = pic }
then in code or designer:
button1.mousehover += common_mousehover; button2.mousehover += common_mousehover; .. etc
Comments
Post a Comment