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

How to get the arclen between two curve points in Maya? -

git svn - Unignore directories in git-svn (adding directories to a sparse checkout) -

C++ Linked List -