What’s the purpose of the components IContainer generated by the Winforms designer?

When you add non-UI components to the form (such as a Timer component), components will be the parent of those compoments. The code in the designer file makes sure that these components are disposed of when the form is disposed. If you have not added any such components to the form in design time, components will be null.

Since components is designer generated, and will be null if you have no non-UI compoments on the form (in design time), I would personally opt for managing those components in some other way, disposing them on form close or something like that.

Leave a Comment