500pts: Generic unsubscribing an event?
Posted on 2007-03-28
I wonder if anyone can help, i need to unsubscribe from an event but i don't know the method at runtime.. Probably better if i explain with an example..
myGraphics.Click += new EventHandler(myGraphics_Click); // this is set in a form of some kind..
I then pass around myGraphics to difference forms so i need to reset the .Click event to myGraphics_Click but the problem is that it is still set to myGraphics_click on the original form before it was passed so hence the event fires on both forms :-)
Is there a way i can NULL the click event or something, or iterate through all subscribers to the click event so i can decide how to unsubscribe..
The problem is that i will probably have to unsubscribe the original form when i have arrived in my new form...
Confused? I am :-) .... Any ideas how to do this... really apprecaite any help
thanks in advance