Remove Event Handle dynamically in C#

J

Jensen Hoh

How can I remove a event handle dynamically?

I knew that, it is the proper way to add a event handler for a control

Add Handler
-----------------------------------------------
this.button1.Click += new System.EventHandler(this.button1_Click);

Remove Handler
------------------------------------------------
button1.Click -= new System.EventHandler(button1_Click);

But I want some other way which is more easy, which doesn't need to
supply the old method pointer(name) in the procedure..

A good example is like example below ( written in Delphi )
button1.onClick := nil;

Does anyone can help me or give me a hint. TQ...
 
H

http://www.visual-basic-data-mining.net/forum

Have you tried the syntax RemoveHandler object.EventA, AddressOf
Me.EventHandler
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top