This is the discussion forum for the HtmlEditor. See also the
HtmlEditor home page, where you can download the control, and the
Documentation Wiki, a collaborative project for documenting the control.
Event handlers in CloseDocument
Posted by:
Peter Wone (---.dyn.iinet.net.au)
Date: Saturday, 07-Jan-2006, 02:02:24
Correct me if I'm wrong but as far as I can see this excerpt from htmlsite.CloseDocument() cannot possibly be correct code.
container.Resize -= new EventHandler(this.Container_Resize);
The -= operator removes a delegate instance from the collection of delegates implied by an event declaration. The code above manufactures a NEW instance and it therefore won't be found, and therefore won't be removed. This code, though legal, has no effect other than slightly increasing transient memory consumption.
If you want to unhitch from the event you need to keep a reference to the delegate instance and pass that. So htmlsite needs a member
EventHandler containerResizeDelegateInstance;
which must be initialized in the constructor
containerResizeDelegateInstance = new EventHandler(Container_Resize);
You (un)bind it like this
container.Resize += containerResizeDelegateInstance;
container.Resize -= containerResizeDelegateInstance;