By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,294 Members | 2,645 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,294 IT Pros & Developers. It's quick & easy.

Remove Event Handlers in C#

P: n/a

I am currently working on C#.

I need to temporarity add remove event handlers
which i was done in VB.NET using Addhandler and RemoveHandler functions.

How to do it in c#

Thanks in Advance
Prasad Dannani

Nov 17 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a

The += and -= are what you are after.

For example, say I have a combo box and I want to add an event handler
to the index changed event. It is as easy as:

cmbFonts.SelectedIndexChanged += new

Where my event handling routine matches the signature of the
EventHandler delegate. For example:

private void cmbFonts_SelectedIndexChanged(object sender,
System.EventArgs e)
// Do some work here

When I want to remove the event handler:
cmbFonts.SelectedIndexChanged -= new


Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.