Container 類別

定義

封裝零個或多個元件。Encapsulates zero or more components.

public ref class Container : IDisposable, System::ComponentModel::IContainer
public class Container : IDisposable, System.ComponentModel.IContainer
type Container = class
    interface IContainer
    interface IDisposable
Public Class Container
Implements IContainer, IDisposable
繼承
Container
衍生
實作

備註

類別是IContainer介面的預設實值。 ContainerThe 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.

建構函式

Container()

初始化 Container 類別的新執行個體。Initializes a new instance of the Container class.

屬性

Components

取得 Container 中的所有元件。Gets all the components in the Container.

方法

Add(IComponent)

將指定的 Component 加入至 ContainerAdds the specified Component to the Container. 元件未命名。The component is unnamed.

Add(IComponent, String)

將指定的 Component 加入 Container,並指派名稱給它。Adds the specified Component to the Container and assigns it a name.

CreateSite(IComponent, String)

為指定的 ISite 建立站台 IComponent,並將指定的名稱指派給站台。Creates a site ISite for the given IComponent and assigns the given name to the site.

Dispose()

釋放 Container 所使用的所有資源。Releases all resources used by the Container.

Dispose(Boolean)

釋放 Container 所使用的 Unmanaged 資源,並選擇性釋放 Managed 資源。Releases the unmanaged resources used by the Container, and optionally releases the managed resources.

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
Finalize()

釋出 Unmanaged 資源並執行其他清除作業後,記憶體回收才能重新回收 ContainerReleases unmanaged resources and performs other cleanup operations before the Container is reclaimed by garbage collection.

GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetService(Type)

取得指定型別的服務物件 (如果有的話)。Gets the service object of the specified type, if it is available.

GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(繼承來源 Object)
Remove(IComponent)

Container 移除元件。Removes a component from the Container.

RemoveWithoutUnsiting(IComponent)

Container 移除元件,而不必將 Site 設定為 nullRemoves a component from the Container without setting Site to null.

ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)
ValidateName(IComponent, String)

判斷元件名稱對這個容器而言是否唯一。Determines whether the component name is unique for this container.

適用於

另請參閱