Container Class
 

Encapsulates zero or more components.

Namespace:   System.ComponentModel
Assembly:  System (in System.dll)

SystemObject
  System.ComponentModelContainer
     System.ComponentModelNestedContainer

[HostProtectionAttribute(SecurityAction.LinkDemand, SharedState = true)]
public class Container : IContainer, IDisposable
[HostProtectionAttribute(SecurityAction::LinkDemand, SharedState = true)]
public ref class Container : IContainer, IDisposable
[<HostProtectionAttribute(SecurityAction.LinkDemand, SharedState = true)>]
type Container = 
    class
        interface IContainer
        interface IDisposable
    end
<HostProtectionAttribute(SecurityAction.LinkDemand, SharedState := True)>
Public Class Container
	Implements IContainer, IDisposable
NameDescription
System_CAPS_pubmethod Container

Initializes a new instance of the Container class.

NameDescription
System_CAPS_pubproperty

Gets all the components in the Container.

NameDescription
System_CAPS_pubmethod Add

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

System_CAPS_pubmethod Add

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

System_CAPS_protmethod CreateSite

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

System_CAPS_pubmethod Dispose

Releases all resources used by the Container.

System_CAPS_protmethod Dispose

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

System_CAPS_pubmethod Equals

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethod Finalize

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

System_CAPS_pubmethod GetHashCode

Serves as the default hash function. (Inherited from Object.)

System_CAPS_protmethod GetService

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

System_CAPS_pubmethod GetType

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethod MemberwiseClone

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethod Remove

Removes a component from the Container.

System_CAPS_protmethod RemoveWithoutUnsiting

Removes a component from the Container without setting to null.

System_CAPS_pubmethod ToString

Returns a string that represents the current object.(Inherited from Object.)

System_CAPS_protmethod ValidateName

Determines whether the component name is unique for this container.

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.

.NET Framework
Available since 1.1

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top