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

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

React Native allow user to reorder elements in a scrollview list -

multithreading - Exception in Application constructor -