DesignSurface DesignSurface DesignSurface DesignSurface Class


Presents a user interface for designing components.

public ref class DesignSurface : IDisposable, IServiceProvider
public class DesignSurface : IDisposable, IServiceProvider
type DesignSurface = class
    interface IDisposable
    interface IServiceProvider
Public Class DesignSurface
Implements IDisposable, IServiceProvider


The DesignSurface class implements what the user perceives as a designer. DesignSurface is the user interface the user manipulates to change design-time features. DesignSurface provides a completely self-contained design surface.

The DesignSurface class may be used as a stand-alone designer, or it may be coupled with the DesignSurfaceManager class to provide a common implementation for an application that hosts multiple DesignSurface objects.

The DesignSurface class can be used by itself, or the user can derive a new class from it and augment the behavior.

The DesignSurface class provides several design-time services automatically. The DesignSurface class adds all of its services in its constructor. Most of these services can be overridden by replacing them in the protected ServiceContainer property. To replace a service, override the constructor, call base, and make any changes through the protected ServiceContainer property. All services that are added to the service container and that implement IDisposable are disposed when the design surface is disposed. The default set of replaceable services that the DesignSurface class provides is shown in the following table.

Service Description
IExtenderProviderService Enables objects that are not part of the container's components collection to provide their own extender providers.
IExtenderListService Used by TypeDescriptor to get a list of extender providers. With this service, extender providers can live outside of the container.
ITypeDescriptorFilterService Provides designer metadata hooks. This is the primary interface for metadata filtering.
ISelectionService Provides a way to select components in the designer.
IReferenceService Provides a way to get a name for objects, even when those objects are not sited.
DesignSurface Offers the design surface itself as a service.
DesignerOptionService Provides a base class for getting and setting option values for a designer.

The following table shows the non-replaceable services provided by default.

Service Description
IComponentChangeService Raises events as changes are made to components.
IDesignerHost Controls access to types, services, and transactions. Master interface for designers.
IContainer Owns the set of components that are being designed. Each designer has an IContainer that owns the components.
IServiceContainer Derives from IServiceProvider and provides a way to add and remove services from the designer.

In addition to these services, the DesignSurface class also provides a single service that is available through a component's site. This service is unique for each component. The following table shows the services that cannot be replaced.

Service Description
IDictionaryService A generic dictionary of key/value pairs that can be used to store arbitrary data about a component.
INestedContainer A container that enables a component to add additional child components to the designer. These components will be part of the design surface, but will not participate in serialization. This is useful when you want to design a control that is capable of exposing a region of itself in a designer, but you do not want the region to participate in serialization.

In addition to ISite, the site also implements the following interfaces.


Check for the existence of these interfaces, rather than use indiscriminate casting, because other site implementations may not implement them.

Service Description
IServiceContainer Provides a way to get to the container of site-specific services. For example, IDictionaryService is a site-specific service. With this service, you can add additional site-specific services.


DesignSurface() DesignSurface() DesignSurface() DesignSurface()

Initializes a new instance of the DesignSurface class.

DesignSurface(IServiceProvider) DesignSurface(IServiceProvider) DesignSurface(IServiceProvider) DesignSurface(IServiceProvider)

Initializes a new instance of the DesignSurface class.

DesignSurface(IServiceProvider, Type) DesignSurface(IServiceProvider, Type) DesignSurface(IServiceProvider, Type) DesignSurface(IServiceProvider, Type)

Initializes a new instance of the DesignSurface class.

DesignSurface(Type) DesignSurface(Type) DesignSurface(Type) DesignSurface(Type)

Initializes a new instance of the DesignSurface class.


ComponentContainer ComponentContainer ComponentContainer ComponentContainer

Gets the IContainer implementation within the design surface.

DtelLoading DtelLoading DtelLoading DtelLoading

Gets a value indicating whether the Design-time Error List is loading.

IsLoaded IsLoaded IsLoaded IsLoaded

Gets a value indicating whether the design surface is currently loaded.

LoadErrors LoadErrors LoadErrors LoadErrors

Returns a collection of loading errors or a void collection.

ServiceContainer ServiceContainer ServiceContainer ServiceContainer

Gets the service container.

View View View View

Gets the view for the root designer.


BeginLoad(DesignerLoader) BeginLoad(DesignerLoader) BeginLoad(DesignerLoader) BeginLoad(DesignerLoader)

Begins the loading process with the given designer loader.

BeginLoad(Type) BeginLoad(Type) BeginLoad(Type) BeginLoad(Type)

Begins the loading process.

CreateComponent(Type) CreateComponent(Type) CreateComponent(Type) CreateComponent(Type)

Creates an instance of a component.

CreateDesigner(IComponent, Boolean) CreateDesigner(IComponent, Boolean) CreateDesigner(IComponent, Boolean) CreateDesigner(IComponent, Boolean)

Creates a designer when a component is added to the container.

CreateInstance(Type) CreateInstance(Type) CreateInstance(Type) CreateInstance(Type)

Creates an instance of the given type.

CreateNestedContainer(IComponent) CreateNestedContainer(IComponent) CreateNestedContainer(IComponent) CreateNestedContainer(IComponent)

Creates a container suitable for nesting controls or components.

CreateNestedContainer(IComponent, String) CreateNestedContainer(IComponent, String) CreateNestedContainer(IComponent, String) CreateNestedContainer(IComponent, String)

Creates a container suitable for nesting controls or components.

Dispose() Dispose() Dispose() Dispose()

Releases the resources used by the DesignSurface.

Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

Releases the resources used by the DesignSurface.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
Flush() Flush() Flush() Flush()

Serializes changes to the design surface.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetService(Type) GetService(Type) GetService(Type) GetService(Type)

Gets a service from the service container.

GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
OnLoaded(LoadedEventArgs) OnLoaded(LoadedEventArgs) OnLoaded(LoadedEventArgs) OnLoaded(LoadedEventArgs)

Raises the Loaded event.

OnLoading(EventArgs) OnLoading(EventArgs) OnLoading(EventArgs) OnLoading(EventArgs)

Raises the Loading event.

OnUnloaded(EventArgs) OnUnloaded(EventArgs) OnUnloaded(EventArgs) OnUnloaded(EventArgs)

Raises the Unloaded event.

OnUnloading(EventArgs) OnUnloading(EventArgs) OnUnloading(EventArgs) OnUnloading(EventArgs)

Raises the Unloading event.

OnViewActivate(EventArgs) OnViewActivate(EventArgs) OnViewActivate(EventArgs) OnViewActivate(EventArgs)

Raises the ViewActivated event.

ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)


Disposed Disposed Disposed Disposed

Occurs when the design surface is disposed.

Flushed Flushed Flushed Flushed

Occurs when a call is made to the Flush() method of DesignSurface.

Loaded Loaded Loaded Loaded

Occurs when the designer load has completed.

Loading Loading Loading Loading

Occurs when the designer is about to be loaded.

Unloaded Unloaded Unloaded Unloaded

Occurs when a designer has finished unloading.

Unloading Unloading Unloading Unloading

Occurs when a designer is about to unload.

ViewActivated ViewActivated ViewActivated ViewActivated

Occurs when the Activate() method has been called on IDesignerHost.


for full access to system resources. Demand values: LinkDemand, InheritanceDemand. Associated state:

Applies to

See also