Export (0) Print
Expand All

NestedContainer Class

Provides the base implementation for the INestedContainer interface, which enables containers to have an owning component.

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

public class NestedContainer : Container, INestedContainer, IContainer, IDisposable
public class NestedContainer extends Container implements INestedContainer, IContainer, 
	IDisposable
public class NestedContainer extends Container implements INestedContainer, IContainer, 
	IDisposable
Not applicable.

The NestedContainer class is a simple implementation of the INestedContainer interface, which defines a component that logically contains zero or more other components and is owned by a parent component. The behavior of nested containers differs from a standard Container in a number of ways, including the following:

  • Site characteristics such as DesignMode and GetService are routed through the owning component’s site.

  • The site’s Name property is a qualified name that includes the owning component’s name followed by a period (.) and the child component’s name.

  • GetService provides support for the INestedContainer as a service.

  • When the owning component is disposed, the container is disposed as well.

In addition, designers treat nested containers differently. A designer host is only interested in one container—the one associated with the host. Therefore, component add and remove events are not raised when a component is added to or removed from a nested container. However, because services flow through to the nested container, component change events are raised when a component in a nested container is changed.

This disparity in event tracking also impacts undo functionality, which is closely tied to serialization. The standard undo engine uses IReferenceService to track changes made to components. If the undo engine cannot identify a name for a component through the reference service, the engine will ignore any changes for that component. This service automatically recognizes changes to contained components only if they are exposed as public read-only properties of the same name in their owners. Otherwise, the developer must pass component change events up to the owner. For example, if a nested component’s Text property is resurfaced on its owning component as an Address property, when the Text property is changed, a property change must be programmatically made for the corresponding Address property or else that change will not be tracked by undo.

NoteNote:

The HostProtectionAttribute attribute applied to this class has the following Resources property value: SharedState. The HostProtectionAttribute does not affect desktop applications (which are typically started by double-clicking an icon, typing a command, or entering a URL in a browser). For more information, see the HostProtectionAttribute class or SQL Server Programming and Host Protection Attributes.

System.Object
   System.ComponentModel.Container
    System.ComponentModel.NestedContainer

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

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft