PanelContainerDesigner クラス
アセンブリ: System.Design (system.design.dll 内)


Panel コントロールは、特にコントロールがプログラムで生成されたときに、他のコントロールのコンテナとして使用されます。
ビジュアルなデザイナで、ソース ビューからデザイン ビューに切り替えると、関連付けられた Panel コントロールを記述するマークアップのソース コードが解析され、コントロールのデザイン時バージョンがデザイン サーフェイスに作成されます。元のソース ビューに切り替えると、デザイン時のコントロールがマークアップのソース コードに保持され、Web ページのマークアップに反映されます。PanelContainerDesigner クラスは、ビジュアルなデザイナで、Panel コントロールをデザイン時に使用できるようにします。
FrameCaption プロパティは、関連付けられた Panel コントロールに表示されるキャプションを取得します。FrameStyle プロパティは、関連付けられたコントロールのスタイルを取得します。
UsePreviewControl プロパティは、常に true を返します。デザイナは、関連付けられた Panel の一時的なコピーを作成して、デザイン時のマークアップを生成します。
Initialize メソッドは、関連付けられた Panel コントロールをデザイナで表示、編集、デザインできるように準備します。AddDesignTimeCssAttributes メソッドは、コレクションの要素を、関連付けられたコントロールのざまざまなスタイル属性 (文字列形式) に設定します。

PanelContainerDesigner クラスを拡張し、Panel コントロールから派生したコントロールの外観と動作をデザイン時に変更するコード例を次に示します。
この例では、MyPanelContainer クラスを Panel コントロールから派生させています。また、PanelContainerDesigner クラスから MyPanelContainerDesigner クラスを派生させ、MyPanelContainer クラスの MyPanelContainerDesigner に DesignerAttribute 属性を適用しています。
MyPanelContainerDesigner は、次の PanelContainerDesigner のメンバをオーバーライドします。
-
MyPanelContainer コントロールのデザイン時の境界線スタイルを定義する FrameStyle プロパティ。
-
MyPanelContainer コントロールでキャプションが定義されていない場合に、このコントロールに既定のキャプションを提供する FrameCaption プロパティ。
-
関連付けられたコントロールが MyPanelContainer オブジェクトではない場合に ArgumentException 例外をスローする Initialize メソッド。
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
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

System.ComponentModel.Design.ComponentDesigner
System.Web.UI.Design.HtmlControlDesigner
System.Web.UI.Design.ControlDesigner
System.Web.UI.Design.ContainerControlDesigner
System.Web.UI.Design.WebControls.PanelContainerDesigner


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
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- PanelContainerDesigner クラスのページへのリンク