This documentation is archived and is not being maintained.

ContainerControlDesigner Class

Note: This class is new in the .NET Framework version 2.0.

Provides designer functionality for controls that contain child controls or properties that can be modified at design time.

Namespace: System.Web.UI.Design
Assembly: System.Design (in system.design.dll)

'Declaration
Public Class ContainerControlDesigner
	Inherits ControlDesigner
'Usage
Dim instance As ContainerControlDesigner

public class ContainerControlDesigner extends ControlDesigner
public class ContainerControlDesigner extends ControlDesigner

The ContainerControlDesigner class provides a base designer class for controls that can be modified on the design surface. This includes controls that contain child controls or editable inner properties. The ContainerControlDesigner provides a single framed region to represent the control, and automatically handles rendering the control at design time.

Apply the ParseChildrenAttribute attribute on the associated control to determine the design-time behavior of the ContainerControlDesigner. Apply the ParseChildrenAttribute settings on the associated control as follows:

  • false to indicate that the ContainerControlDesigner represents the contents of the editable design region as child controls.

  • true to indicate that the ContainerControlDesigner represents the contents of the editable design region as editable inner properties of the control.

Control developers can derive and extend a custom designer from one of several base designers depending on the kind of control that is being developed, as defined in the following list:

  • Controls that allow child controls to be added to it at design time can derive from the ContainerControlDesigner class. For example, the PanelContainerDesigner class is derived from the ContainerControlDesigner class and represents a Panel control on the design surface.

  • Controls that have one or more child controls, and might also have an editable designer region where controls can be added at design time, can derive from the CompositeControlDesigner class.

  • Controls that require custom design-time processing can derive from the base ControlDesigner class.

NoteNote

The ContainerControlDesigner class replaces the obsolete ReadWriteControlDesigner class.

Use the DesignerAttribute attribute to associate a custom designer class together with a custom control implementation. For detailed information about how to use control designers with custom controls, see Walkthrough: Creating a Basic Control Designer for a Web Server Control.

The following code example demonstrates how to derive a designer class from the ContainerControlDesigner class. The example defines a simple control that is derived from the CompositeControl class, and then defines an associated designer, which is derived from the ContainerControlDesigner class. The derived designer class overrides the FrameCaption and FrameStyle properties to customize the frame that is around the editable region of the control on the design surface.


Imports Microsoft.VisualBasic
Imports System
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Collections
Imports System.Drawing
Imports System.Web.UI
Imports System.Web.UI.Design
Imports System.Web.UI.Design.WebControls
Imports System.Web.UI.WebControls

Namespace ControlDesignerSamples.VB


    ' Define a simple composite control, derived from the 
    ' System.Web.UI.WebControls.CompositeControl class.

    <Designer(GetType(SimpleContainerControlDesigner)), _
     ParseChildren(False)> _
    Public Class SimpleContainerControl
        Inherits CompositeControl

    End Class


    ' Define the designer for the simple composite control.
    ' The designer derives from System.Web.UI.Design.ContainerControlDesigner.
    ' The designer defines the style and caption for the frame around the 
    ' editable region of the control in the design surface.
    Public Class SimpleContainerControlDesigner
        Inherits ContainerControlDesigner

        Private _style As Style = Nothing

        ' Define the caption text for the frame in the design surface.
        Public Overrides ReadOnly Property FrameCaption() As String
            Get
                Return "- My simple container control -"
            End Get
        End Property


        ' Define the style of the frame around the control in the design surface.
        Public Overrides ReadOnly Property FrameStyle() As Style
            Get
                If _style Is Nothing Then

                    _style = New Style()
                    _style.Font.Name = "Verdana"
                    _style.Font.Size = New FontUnit("XSmall")
                    _style.BackColor = Color.LavenderBlush
                    _style.ForeColor = Color.DarkBlue
                End If

                Return _style
            End Get
        End Property


    End Class

End Namespace

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 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0
Show: