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

multithreading - Exception in Application constructor -

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

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -