PanelContainerDesigner 类  
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
在可视化设计器中为 Panel 控件提供设计时支持。
public ref class PanelContainerDesigner : System::Web::UI::Design::ContainerControlDesignerpublic class PanelContainerDesigner : System.Web.UI.Design.ContainerControlDesignertype PanelContainerDesigner = class
    inherit ContainerControlDesignerPublic Class PanelContainerDesigner
Inherits ContainerControlDesigner- 继承
- 
				PanelContainerDesigner
示例
下面的代码示例演示如何扩展 PanelContainerDesigner 类,以更改在设计时派生自 控件 Panel 的控件的外观和行为。
该示例从 Panel 控件派生 MyPanelContainer 类。 该示例还从 类派生 MyPanelContainerDesigner 类,PanelContainerDesigner并在 类上MyPanelContainer应用 DesignerAttribute 属性MyPanelContainerDesigner。
将 MyPanelContainerDesigner 替代以下 PanelContainerDesigner 成员:
- 用于 FrameStyle 定义控件的设计时边框样式的属性 - MyPanelContainer。
- 用于 FrameCaption 为 - MyPanelContainer控件提供默认标题(如果未定义)的属性。
- 如果Initialize关联的控件不是 - MyPanelContainer对象,则引发ArgumentException异常的方法。
using System;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.Design.WebControls;
using System.ComponentModel;
using System.Security.Permissions;
namespace Examples.CS.WebControls.Design
{
    // The MyPanelContainer is a copy of the Panel.
    [AspNetHostingPermission(SecurityAction.Demand, 
        Level = AspNetHostingPermissionLevel.Minimal)]
    [AspNetHostingPermission(SecurityAction.InheritanceDemand, 
        Level = AspNetHostingPermissionLevel.Minimal)]
    [Designer(typeof(Examples.CS.WebControls.Design.MyPanelContainerDesigner))]
    public class MyPanelContainer : Panel
    {
    } // MyPanelContainer
    // Override members of the PanelContainerDesigner.
    public class MyPanelContainerDesigner : PanelContainerDesigner
    {
        // Provide a design-time caption for the panel.
        public override string FrameCaption 
        {
            get
            {
                // If the FrameCaption is empty, use the panel control ID.
                string localCaption = base.FrameCaption;
                if (localCaption == null || localCaption == "")
                    localCaption = ((Panel)Component).ID.ToString();
                return localCaption;
            }
        } // FrameCaption
        // Provide a design-time border style for the panel.
        public override Style FrameStyle
        {
            get
            {
                Style styleOfFrame = base.FrameStyle;
                // If no border style is defined, define one.
                if (styleOfFrame.BorderStyle == BorderStyle.NotSet ||
                    styleOfFrame.BorderStyle == BorderStyle.None)
                    styleOfFrame.BorderStyle = BorderStyle.Outset;
                return styleOfFrame;
            }
        } // FrameStyle
        // Initialize the designer.
        public override void Initialize(IComponent component)
        {
            // Ensure that only a MyPanelContainer can be created 
            // in this designer.
            if (!(component is MyPanelContainer))
                throw new ArgumentException();
            
            base.Initialize(component);
        } // Initialize
    } // MyPanelContainerDesigner
} // Examples.CS.WebControls.Design
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
    ' 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
    End Class
End Namespace ' Examples.VB.WebControls.Design
注解
控件 Panel 用作其他控件的容器,尤其是在以编程方式生成控件时。
在可视化设计器中,从“源”切换到“设计”视图时,将分析描述关联 Panel 控件的标记源代码,并在设计图面上创建控件的设计时版本。 切换回“源”视图时,设计时控件将保留以标记源代码,并编辑为网页的标记。 类 PanelContainerDesigner 为可视化设计器中的控件提供设计时支持 Panel 。
属性 FrameCaption 获取显示在关联 Panel 控件上的标题。 属性 FrameStyle 获取关联控件的样式。
属性 UsePreviewControl 始终返回 true,指示设计器创建关联的 Panel 的临时副本以生成设计时标记。
方法 Initialize 使设计器准备好查看、编辑和设计关联的 Panel 控件。 方法 AddDesignTimeCssAttributes 将集合元素设置为关联控件的各种样式属性的字符串表示形式。
构造函数
| PanelContainerDesigner() | 初始化 PanelContainerDesigner 类的新实例。 | 
属性
| ActionLists | 获取控件设计器的操作列表集合。(继承自 ControlDesigner) | 
| AllowResize | 获取一个值,该值指示控件的大小在设计时是否可以调整。(继承自 ContainerControlDesigner) | 
| AssociatedComponents | 获取与设计器所管理的组件关联的组件集合。(继承自 ComponentDesigner) | 
| AutoFormats | 获取预定义自动格式设置方案的集合,这些方案将在设计时显示于关联控件的“自动套用格式”对话框中。(继承自 ControlDesigner) | 
| Behavior | 
		已过时.
	 获取或设置与设计器关联的 DHTML 行为。(继承自 HtmlControlDesigner) | 
| Component | 获取此设计器正在设计的组件。(继承自 ComponentDesigner) | 
| DataBindings | 获取当前控件的数据绑定集合。(继承自 HtmlControlDesigner) | 
| DataBindingsEnabled | 获取一个值,该值指示包含关联控件的区域是否支持数据绑定。(继承自 ControlDesigner) | 
| DesignerState | 获取用于在设计时保持关联控件数据的对象。(继承自 ControlDesigner) | 
| DesignTimeElement | 
		已过时.
	 获取一个设计时对象,该对象表示与设计图面上的 HtmlControlDesigner 对象关联的控件。(继承自 HtmlControlDesigner) | 
| DesignTimeElementView | 
		已过时.
	 获取控件设计器的视图控件对象。(继承自 ControlDesigner) | 
| DesignTimeHtmlRequiresLoadComplete | 
		已过时.
	 获取一个值,该值指示是否必须在设计宿主完成加载之后才能调用 GetDesignTimeHtml 方法。(继承自 ControlDesigner) | 
| Expressions | 获取当前控件在设计时的表达式绑定。(继承自 HtmlControlDesigner) | 
| FrameCaption | 获取在关联 Panel 控件上显示的标题。 | 
| FrameStyle | 获取关联 Panel 控件的样式。 | 
| HidePropertiesInTemplateMode | 获取一个值,该值指示当控件处于模板模式时,关联控件的属性是否被隐藏。(继承自 ControlDesigner) | 
| ID | 获取或设置控件的 ID 字符串。(继承自 ControlDesigner) | 
| InheritanceAttribute | 获取一个特性,该特性指示关联组件的继承类型。(继承自 ComponentDesigner) | 
| Inherited | 获取一个值,该值指示是否继承此组件。(继承自 ComponentDesigner) | 
| InTemplateMode | 获取一个值,该值指示控件在设计宿主中是否处于模板查看模式或模板编辑模式之一。 InTemplateMode 属性为只读。(继承自 ControlDesigner) | 
| IsDirty | 
		已过时.
	 获取或设置一个值,该值指示 Web 服务器控件是否已被标记为已更改。(继承自 ControlDesigner) | 
| NoWrap | 获取指定是否在窗口中使用的 HTML  | 
| ParentComponent | 获取此设计器的父组件。(继承自 ComponentDesigner) | 
| ReadOnly | 
		已过时.
	 获取或设置一个值,该值指示控件的属性在设计时是否为只读。(继承自 ControlDesigner) | 
| RootDesigner | 获取包含关联控件的 Web 窗体页的控件设计器。(继承自 ControlDesigner) | 
| SetTextualDefaultProperty | 在可视化设计器中为 Panel 控件提供设计时支持。(继承自 ComponentDesigner) | 
| ShadowProperties | 获取重写用户设置的属性值的集合。(继承自 ComponentDesigner) | 
| ShouldCodeSerialize | 
		已过时.
	 获取或设置一个值,该值指示在序列化期间是否应为当前设计文档在代码隐藏文件中创建控件的字段声明。(继承自 HtmlControlDesigner) | 
| Tag | 获取表示关联控件的 HTML 标记元素的对象。(继承自 ControlDesigner) | 
| TemplateGroups | 获取一个模板组集合,其中每个模板组包含一个或多个模板定义。(继承自 ControlDesigner) | 
| UsePreviewControl | 获取一个值,指示设计器是否应使用临时副本取代与设计器关联的实际控件来生成设计时标记。 | 
| Verbs | 获取与设计器相关联的组件所支持的设计时谓词。(继承自 ComponentDesigner) | 
| ViewControl | 获取或设置可用于预览设计时 HTML 标记的 Web 服务器控件。(继承自 ControlDesigner) | 
| ViewControlCreated | 获取或设置一个值,该值指示是否已创建  | 
| Visible | 获取指示该控件在设计时是否可见的值。(继承自 ControlDesigner) | 
方法
显式接口实现
| IDesignerFilter.PostFilterAttributes(IDictionary) | 有关此成员的说明,请参见 PostFilterAttributes(IDictionary) 方法。(继承自 ComponentDesigner) | 
| IDesignerFilter.PostFilterEvents(IDictionary) | 有关此成员的说明,请参见 PostFilterEvents(IDictionary) 方法。(继承自 ComponentDesigner) | 
| IDesignerFilter.PostFilterProperties(IDictionary) | 有关此成员的说明,请参见 PostFilterProperties(IDictionary) 方法。(继承自 ComponentDesigner) | 
| IDesignerFilter.PreFilterAttributes(IDictionary) | 有关此成员的说明,请参见 PreFilterAttributes(IDictionary) 方法。(继承自 ComponentDesigner) | 
| IDesignerFilter.PreFilterEvents(IDictionary) | 有关此成员的说明,请参见 PreFilterEvents(IDictionary) 方法。(继承自 ComponentDesigner) | 
| IDesignerFilter.PreFilterProperties(IDictionary) | 有关此成员的说明,请参见 PreFilterProperties(IDictionary) 方法。(继承自 ComponentDesigner) | 
| ITreeDesigner.Children | 有关此成员的说明,请参见 Children 属性。(继承自 ComponentDesigner) | 
| ITreeDesigner.Parent | 有关此成员的说明,请参见 Parent 属性。(继承自 ComponentDesigner) |