views:

187

answers:

2

Is WithEvents & Handles usage preferable to RemoveHandler & AddHandler?

From Memory point of view (remove an added handler after utilization, etc.)

Related question.

+1  A: 

Depends what your doing really, if you want to dynamically attach / detach event handlers then using AddHandler/RemoveHandler is the way to go about it otherwise using Handles is perfectly fine.

David
+2  A: 

It depends on what you're trying to achieve. If you have several event handlers which must handle events for various controls during the lifetime of a form/object then WithEvents and Handles is the easiest way to go. The language will do all of the dirty work for you in terms of setting up the event. On the other hand, if you tend to disconnect from events during the lifetime of the form, AddHandler and RemoveHandler are better options.

JaredPar