PanelContainerDesigner Class

Provides design-time support in a visual designer for the Panel control.

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

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

public class PanelContainerDesigner extends ContainerControlDesigner
public class PanelContainerDesigner extends ContainerControlDesigner
Not applicable.

The Panel control is used as a container for other controls, especially when controls are generated programmatically.

In a visual designer, when you switch from Source to Design view, the markup source code that describes the associated Panel control is parsed, and a design-time version of the control is created on the design surface. When you switch back to Source view, the design-time control is persisted to markup source code and edited into the markup for the Web page. The PanelContainerDesigner class provides design-time support for Panel controls in a visual designer.

The FrameCaption property gets the caption that appears on the associated Panel control. The FrameStyle property gets the styles of the associated control.

The UsePreviewControl property always returns true, indicating that the designer creates a temporary copy of the associated Panel to generate the design-time markup.

The Initialize method prepares the designer to view, edit, and design the associated Panel control. The AddDesignTimeCssAttributes method sets collection elements to the string representations of various style attributes of the associated control.

The following code example shows how to extend the PanelContainerDesigner class to change the appearance and behavior of controls that are derived from the Panel control at design time.

The example derives the MyPanelContainer class from the Panel control. The example also derives the MyPanelContainerDesigner class from the PanelContainerDesigner class and applies a DesignerAttribute attribute for the MyPanelContainerDesigner on the MyPanelContainer class.

The MyPanelContainerDesigner overrides the following PanelContainerDesigner members:

  • The FrameStyle property to define a design-time border style for the MyPanelContainer control.

  • The FrameCaption property to provide a default caption for the MyPanelContainer control, if none was defined.

  • The Initialize method to throw an ArgumentException exception, if the associated control is not a MyPanelContainer object.

Imports System
Imports System.Web
Imports System.Web.UI.WebControls
Imports System.Web.UI.Design.WebControls
Imports System.ComponentModel
Imports System.Security.Permissions

Namespace Examples.VB.WebControls.Design

    ' The MyPanelContainer is a copy of the PanelContainer.
    <AspNetHostingPermission(SecurityAction.Demand, _
        Level:=AspNetHostingPermissionLevel.Minimal)> _
    <AspNetHostingPermission(SecurityAction.InheritanceDemand, _
        Level:=AspNetHostingPermissionLevel.Minimal)> _
    <Designer(GetType(Examples.VB.WebControls.Design.MyPanelContainerDesigner))> _
    Public Class MyPanelContainer
        Inherits Panel
    End Class ' MyPanelContainer

    ' Override members of the PanelContainerDesigner.
    Public Class MyPanelContainerDesigner
        Inherits PanelContainerDesigner

        ' Provide a design-time caption for the panel.
        Public Overrides ReadOnly Property FrameCaption() As String
            Get
                ' If the FrameCaption is empty, use the panel control ID.
                Dim localCaption As String = MyBase.FrameCaption
                If localCaption Is Nothing Or localCaption = "" Then
                    localCaption = CType(Component, Panel).ID.ToString()
                End If

                Return localCaption
            End Get
        End Property ' FrameCaption

        ' Provide a design-time border style for the panel.
        Public Overrides ReadOnly Property FrameStyle() As Style
            Get
                Dim styleOfFrame As Style = MyBase.FrameStyle

                ' If no border style is defined, define one.
                If (styleOfFrame.BorderStyle = BorderStyle.NotSet Or _
                    styleOfFrame.BorderStyle = BorderStyle.None) Then
                    styleOfFrame.BorderStyle = BorderStyle.Outset
                End If

                Return styleOfFrame
            End Get
        End Property ' FrameStyle

        ' Initialize the designer.
        Public Overrides Sub Initialize(ByVal component As IComponent)

            ' Ensure that only a MyPanelContainer can be created   
            ' in this designer. 
            If Not TypeOf component Is MyPanelContainer Then
                Throw New ArgumentException()
            End If

            MyBase.Initialize(component)

        End Sub ' Initialize
    End Class ' MyPanelContainerDesigner
End Namespace ' Examples.VB.WebControls.Design

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 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: