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

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

Laravel mail error `Swift_TransportException in StreamBuffer.php line 269: Connection could not be established with host smtp.gmail.com [ #0]` -

C#.NET Oracle.ManagedDataAccess ConfigSchema.xsd -