ContainerControlDesigner クラス
アセンブリ: System.Design (system.design.dll 内)
構文
解説ContainerControlDesigner クラスは、デザイン サーフェイスで変更できるコントロールの基本デザイナ クラスを提供します。これには、子コントロールを含むコントロール、または編集可能な内部プロパティが含まれます。ContainerControlDesigner は、コントロールを表すための単一フレーム領域を提供し、デザイン時のコントロールの描画を自動的に処理します。
ContainerControlDesigner のデザイン時の動作を調べるには、関連するコントロールに ParseChildrenAttribute 属性を適用します。ParseChildrenAttribute 設定を、次のように関連するコントロールに適用します。
-
ContainerControlDesigner が、編集可能なデザイン領域の内容を子コントロールとして表す場合は false。
-
ContainerControlDesigner が、編集可能なデザイン領域の内容をコントロールの編集可能な内部プロパティとして表す場合は true。
コントロールの開発者は、開発中のコントロールの種類に応じて、次の一覧で定義されている複数の基本デザイナのうちの 1 つからカスタム デザイナを派生または拡張できます。
-
デザイン時に子コントロールを追加できるコントロールは、ContainerControlDesigner クラスから派生できます。たとえば、PanelContainerDesigner クラスは ContainerControlDesigner クラスから派生し、デザイン サーフェイス上の Panel コントロールを表します。
-
1 つ以上の子コントロールが存在し、デザイン時にコントロールを追加できる編集可能なデザイナ領域も存在する可能性があるコントロールは、CompositeControlDesigner クラスから派生できます。
メモ |
|---|
| ContainerControlDesigner クラスは、使用中止となった ReadWriteControlDesigner クラスに代わるものです。 |
カスタム デザイナ クラスをカスタム コントロール実装と共に関連付けるには、DesignerAttribute 属性を使用します。カスタム コントロールでコントロール デザイナを使用する方法の詳細については、「チュートリアル : Web サーバー コントロール用の基本的なコントロール デザイナの作成」を参照してください。
使用例ContainerControlDesigner クラスからデザイナ クラスを派生する方法を次のコード例に示します。この例では、CompositeControl クラスから派生した単純なコントロールを定義し、次に ContainerControlDesigner クラスから派生した関連デザイナを定義しています。派生デザイナ クラスは、FrameCaption プロパティと FrameStyle プロパティをオーバーライドして、デザイン サーフェイス上のコントロールの編集可能な領域の周囲のフレームをカスタマイズします。
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
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; } } } }
.NET Framework のセキュリティ
継承階層System.ComponentModel.Design.ComponentDesigner
System.Web.UI.Design.HtmlControlDesigner
System.Web.UI.Design.ControlDesigner
System.Web.UI.Design.ContainerControlDesigner
System.Web.UI.Design.WebControls.MultiViewDesigner
System.Web.UI.Design.WebControls.PanelContainerDesigner
System.Web.UI.Design.WebControls.ViewDesigner
スレッド セーフ
プラットフォーム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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照- ContainerControlDesigner クラスのページへのリンク
.gif)