NestedContainer 类

定义

提供 INestedContainer 接口的基实现,该接口使容器可以拥有一个所属组件。

public ref class NestedContainer : System::ComponentModel::Container, IDisposable, System::ComponentModel::IContainer, System::ComponentModel::INestedContainer
public ref class NestedContainer : System::ComponentModel::Container, IDisposable, System::ComponentModel::INestedContainer
public ref class NestedContainer : System::ComponentModel::Container, System::ComponentModel::INestedContainer
public class NestedContainer : System.ComponentModel.Container, IDisposable, System.ComponentModel.IContainer, System.ComponentModel.INestedContainer
public class NestedContainer : System.ComponentModel.Container, IDisposable, System.ComponentModel.INestedContainer
public class NestedContainer : System.ComponentModel.Container, System.ComponentModel.INestedContainer
type NestedContainer = class
    inherit Container
    interface IContainer
    interface IDisposable
    interface INestedContainer
type NestedContainer = class
    inherit Container
    interface INestedContainer
    interface IContainer
    interface IDisposable
Public Class NestedContainer
Inherits Container
Implements IContainer, IDisposable, INestedContainer
Public Class NestedContainer
Inherits Container
Implements IDisposable, INestedContainer
Public Class NestedContainer
Inherits Container
Implements INestedContainer
继承
NestedContainer
实现

注解

NestedContainer 类是接口的 INestedContainer 简单实现,它定义逻辑上包含零个或多个其他组件的组件,并且由父组件拥有。 嵌套容器的行为在多种方面不同于标准 Container ,包括以下内容:

  • 网站特征,例如 DesignMode ,并通过 GetService 拥有组件的站点进行路由。

  • 站点 Name 的属性是一个限定的名称,包括拥有组件的名称,后跟句点 (.) 和子组件的名称。

  • GetService 提供对即服务的支持 INestedContainer

  • 释放拥有组件时,也会释放容器。

此外,设计器以不同的方式处理嵌套容器。 设计器主机仅对一个容器感兴趣,即与主机关联的容器。 因此,在将组件添加到嵌套容器或从嵌套容器中删除组件时,不会引发组件添加和删除事件。 但是,由于服务流经嵌套容器,因此当嵌套容器中的组件发生更改时,会引发组件更改事件。

事件跟踪中的这种差异也会影响撤消功能,该功能与序列化密切相关。 标准撤消引擎用于 IReferenceService 跟踪对组件所做的更改。 如果撤消引擎无法通过引用服务标识组件的名称,则引擎将忽略该组件的任何更改。 仅当这些组件在所有者中公开为同名的公共只读属性时,此服务才会自动识别对包含组件的更改。 否则,开发人员必须将组件更改事件传递给所有者。 例如,如果嵌套组件 Text 的属性作为属性重新浮出其自己的组件 Address ,则当属性发生更改时 Text ,必须为相应的 Address 属性以编程方式更改属性,否则该更改不会被撤消跟踪。

构造函数

NestedContainer(IComponent)

初始化 NestedContainer 类的新实例。

属性

Components

获取 Container 中的所有组件。

(继承自 Container)
Owner

获取此嵌套容器的所属组件。

OwnerName

获取所属组件的名称。

方法

Add(IComponent)

将指定的 Component 添加到 Container。 该组件未命名。

(继承自 Container)
Add(IComponent, String)

将指定的 Component 添加到 Container 并为其分配名称。

(继承自 Container)
CreateSite(IComponent, String)

为容器中的组件创建站点。

Dispose()

释放由 Container 使用的所有资源。

(继承自 Container)
Dispose(Boolean)

释放由嵌套容器使用的资源。

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetService(Type)

获取指定类型的服务对象(如果可用)。

GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
Remove(IComponent)

Container 中移除组件。

(继承自 Container)
RemoveWithoutUnsiting(IComponent)

Container 中移除组件,不将 Site 设置为 null

(继承自 Container)
ToString()

返回表示当前对象的字符串。

(继承自 Object)
ValidateName(IComponent, String)

确定组件名称对此容器是否唯一。

(继承自 Container)

适用于

另请参阅