Remove event from a control?

ThienZ

Freshman
Joined
Feb 10, 2005
Messages
45
Location
Germany
Hi,

is it possible to remove or turn an event off (and then on) from a control?

I add an event like this :
C#:
			this.KeyPress += new KeyPressEventHandler(TextBoxMaxNr_KeyPress);

How can i turn it on/off ?

Thx in advance
 
Without having the IDE in front of me im sure the syntax is something like :

Code:
this.KeyPress -= KeyPressEventHandler;
 
I think you do it like this:

Code:
this.KeyPress -= new KeyPressEventHandler(TextBoxMaxNr_KeyPress);
Create the new delegate, and use the -= operator to have that function removed from the list of handlers.
 
Back
Top