Jump to content
  • Advertisement
Sign in to follow this  
Daniel Miller

[.net] IContainer

This topic is 4776 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

MSDN's description is about as generic as can be: IContainer
Containers are objects that encapsulate and track zero or more components. In this context, containment refers to logical containment, not visual containment. You can use components and containers in a variety of scenarios, including scenarios that are both visual and not visual. Notes to Implementers: To be a container, the class must implement the IContainer interface, which supports methods for adding, removing, and retrieving components.
Could someone explain it a little better? Also, is this what a Windows Form uses to store child conrols?

Share this post

Link to post
Share on other sites
For an example see the Container class. (It's just a container; nothing to explain about)

Regarding ChildControls:
The WinForms designer uses two 'containers'.
1. 'Normal' controls like Buttons, Labels etc. are kept as instance variables (Protected Fields) of the form.
2. Controls that need their member Dispose being called on the closing of the form (e.g.: Timer) are stored in the previous way AND are kept in a Container class. The container class calls Dispose on its contained items.

Just drag a button and a timer control on a form and look at the generated code...


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!