The Artima Developer Community
Sponsored Link

C# Answers Forum
Removing EventHendler

1 reply on 1 page. Most recent reply: Feb 13, 2003 8:47 PM by Matt Gerrans

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Branko

Posts: 9
Nickname: orbusian
Registered: Feb, 2003

Removing EventHendler Posted: Feb 12, 2003 11:33 AM
Reply to this message Reply
Advertisement
How can I remove an Eventhandler from a
component (using code)

eventhandler is created:

System.Windows.Forms.Button button1;
button1.Click += new System.EventHandler(button1_Click);

private void button1_Click(object sender, System.EventArgs e){}

now I want to remove it, if some condition is true, for example;


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Removing EventHendler Posted: Feb 13, 2003 8:47 PM
Reply to this message Reply
You could keep a reference to the delegate and do this:
   button1.Click -= button1_Click_Event;

or you could do this:
button1.Click -= new System.EventHandler(button1_Click);

Flat View: This topic has 1 reply on 1 page
Topic: C# Platforms Previous Topic   Next Topic Topic: help to resolve errors

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use