I was wondering how I could set an EventHandler for a button click so that it would replace all other handlers for this objets. Ideally it would be something of the likes of:
button1.Click = MessageBox.Show("Run just this!"); //Yes, the '=' instead of the '+='.
This is because button1 already has a few click events, and I want to, in the determinated situation, overwrite all the other ones.
More examples:
button1.Click += MessageBox.Show("Event #1 has been triggered!");
button1.Click += MessageBox.Show("Event #2 and #1 have been triggered!");
button1.Click = MessageBox.Show("Event #3, and only #3, has been triggered!");
you can try this…
there is a solution on the MSDN forums. The sample code below will remove all
Clickevents frombutton1.you can keep one event on button …..