c# - Who owns controls? -
let's have component this:
class someform : form { private control example; public void stuff() { this.example = new combobox(); // ... this.controls.add(example); } public void otherstuff() { this.controls.remove(example); } } who responsible calling dispose on example control? removing this.controls cause disposed? or leak bunches of window handles backing controls?
(for reference, i'm asking because don't see windows forms designer generates code call dispose on form's children)
form.dispose() dispose of controls within controls collection. removing control controls require dispose of control yourself.
Comments
Post a Comment