Export (0) Print
Expand All

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)

public class ContainerControlDesigner : ControlDesigner
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.

using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Web.UI;
using System.Web.UI.Design;
using System.Web.UI.Design.WebControls;
using System.Web.UI.WebControls;

namespace ControlDesignerSamples.CS
{

    // Define a simple composite control, derived from the 
    // System.Web.UI.WebControls.CompositeControl class.
    [
        Designer(typeof(SimpleContainerControlDesigner)) , 
        ParseChildren(false)
    ]
    public class SimpleContainerControl : CompositeControl
    {
    }


    // 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 frame around the 
    // editable region in the design surface.
    public class SimpleContainerControlDesigner : ContainerControlDesigner
    {
        private Style _style = null;

        // Define the caption text for the frame in the design surface.
        public override string FrameCaption
        {
            get
            {
                return "= My simple container control =";
            }
        }

        // Define the style of the frame around the control in the design surface.
        public override Style FrameStyle
        {
            get
            {
                if (_style == null)
                {
                    _style = new Style();
                    _style.Font.Name = "Verdana";
                    _style.Font.Size = new FontUnit("XSmall");
                    _style.BackColor = Color.LavenderBlush;
                    _style.ForeColor = Color.DarkBlue;
                }

                return _style;
            }
        }
    }
}

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:
© 2014 Microsoft