I have a command button on a winform. So, if I have something like:
myButton.Click += MyHandler1;
myButton.Click += MyHandler2;
myButton.Click += MyHandler3;
How can I tell if any particular MyHandler has already been added to the Click event so it doesn't get added again somewhere else in my code?
I've read how you can use GetInvocationList() for your own event's information. But I get errors when trying to get the items for my command button using various combinations. It says,
"The event 'System.Windows.Forms.Control.Click' can only appear on the left hand side of += or -=."
What am I missing?
[Edit] - I'd like to accentuate this question that Ahmad pointed out. It's a kludge and should be easier IMHO, but it looks like it might just work.
myButton.Click -= MyHandler1
before you add it. – Gristle