OnDestroyHandle() Question
I've extended the combobox control to add my own custom functionality. I've overriden the OnCreateControl() method and load an xml document, which populates my dropdown list. I would like to save my list to xml by overriding the OnHandleDestroyed() method. Is this a good place to put it? I don't want to implement the Dispose() interface, b/c I want to take as much control over this out of the users hands.
Thanks
One thing to know about this method is that it can be called because someone has called "RecreateHandle". Sometimes this can happen when you change particular properties that force Windows Forms to recreate the combobox... so you may be saving more often than you should.
In your code you should make the following check...
if (!this.RecreatingHandle) { // where "this" is your overridden combobox
// save to xml because we're really destroying the combobox.
}
The combo box's handle is destroyed and recreated when changing properties like DropDownStyle or OwnerMode.
an approach would be to load the xml document in the combo box constructor and save it to disk in the dispose method.