System.ComponentModel.Container Class

Encapsulates zero or more components.

See Also: Container


public class Container : IContainer, IDisposable


The Container class is the default implementation for the IContainer interface.

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.

The components in a container are tracked in a first-in, first-out list, which also defines the order of the components within the container. Added components are appended to the end of the list.


Namespace: System.ComponentModel
Assembly: System (in System.dll)
Assembly Versions: 1.0.3300.0, 1.0.5000.0,,

The members of System.ComponentModel.Container are listed below.

See Also: Object

Public Constructors

Initializes a new instance of the Container class.

Public Properties


Gets all the components in the Container.

Public Methods


Adds the specified Component to the Container. The component is unnamed.

Add(IComponent, String)

Adds the specified Component to the Container and assigns it a name.


Releases all resources used by the Container.


Releases unmanaged resources and performs other cleanup operations before the Container is reclaimed by garbage collection.


Removes a component from the Container.

Protected Methods

CreateSite(IComponent, String) : ISite

Creates a site ISite for the given IComponent and assigns the given name to the site.


Releases the unmanaged resources used by the Container, and optionally releases the managed resources.

GetService(Type) : Object

Gets the service object of the specified type, if it is available.


Removes a component from the Container without setting IComponent.Site to null.

ValidateName(IComponent, String)

Determines whether the component name is unique for this container.