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


EditableDesignerRegion クラスを使用すると、デザイン時にテンプレートを管理しやすくなります。ControlDesigner は、自身の GetEditableDesignerRegionContent メソッドと共にこのクラスのインスタンスを使用して、領域のコンテンツの HTML マークアップを生成します。

2 つのクリックできる領域を持つコントロールと、2 つのビュー (テンプレート) を持つ EditableDesignerRegion オブジェクトを作成する方法を次のコード例に示します。デザイン ビューでこのコントロールを表示し、View ボタンをクリックします。各ビューで、コントロールの 1 つを下部にドラッグしてテンプレートの中に配置します。次に、ページの HTML マークアップを表示し、テンプレートがどのようにしてページ内で永続化されているかを確認します。
![]() |
---|
Imports Microsoft.VisualBasic Imports System Imports System.ComponentModel Imports System.ComponentModel.Design Imports System.Drawing Imports System.Web.UI Imports System.Web.UI.Design Imports System.Web.UI.Design.WebControls Imports System.Web.UI.WebControls Namespace Samples.ASPNet.ControlDesigners_VB < _ Designer("MyMultiRegionControlDesigner"), _ ToolboxData("<{0}:MyMultiRgnControl runat=""server"" width=""200""></{0}:MyMultiRgnControl>") _ > _ Public Class MyMultiRgnControl Inherits CompositeControl ' Define the templates that represent 2 views on the control Private _view1 As ITemplate Private _view2 As ITemplate ' The current view on the control; 0 = view1, 1 = view2 Private _currentView As Integer = 0 ' Create persistable inner properties <PersistenceMode(PersistenceMode.InnerProperty), DefaultValue(CType(Nothing, ITemplate))> _ Public Overridable Property View1() As ITemplate Get Return _view1 End Get Set(ByVal value As ITemplate) _view1 = value End Set End Property <PersistenceMode(PersistenceMode.InnerProperty), DefaultValue(CType(Nothing, ITemplate))> _ Public Overridable Property View2() As ITemplate Get Return _view2 End Get Set(ByVal value As ITemplate) _view2 = value End Set End Property Public Property CurrentView() As Integer Get Return _currentView End Get Set(ByVal value As Integer) _currentView = value End Set End Property ' Create a simple table with a row of two clickable, ' readonly headers and a row with a single column, which ' is the 'container' to which we'll be adding controls. Protected Overrides Sub CreateChildControls() ' Start with a clean form Controls.Clear() ' Create a table Dim t As New Table() t.CellSpacing = 1 t.BorderStyle = BorderStyle t.Width = Me.Width t.Height = Me.Height ' Create the header row Dim tr As New TableRow() tr.HorizontalAlign = HorizontalAlign.Center tr.BackColor = Color.LightBlue ' Create the first cell in the header row Dim tc As New TableCell() tc.Text = "View1" tc.Width = New Unit("50%") tr.Cells.Add(tc) ' Create the second cell in the header row tc = New TableCell() tc.Text = "View 2" tc.Width = New Unit("50%") tr.Cells.Add(tc) t.Rows.Add(tr) ' Create the second row for content tr = New TableRow() tr.HorizontalAlign = HorizontalAlign.Center ' This cell represents our content 'container' tc = New TableCell() tc.ColumnSpan = 2 tr.Cells.Add(tc) t.Rows.Add(tr) ' Add the finished table to the Controls collection Controls.Add(t) End Sub End Class ' Region-based control designer for the above web control. ' This is derived from CompositeControlDesigner. Public Class MyMultiRegionControlDesigner Inherits CompositeControlDesigner Private myControl As MyMultiRgnControl Public Sub New() MyBase.New() End Sub Public Overrides Sub Initialize(ByVal component As IComponent) MyBase.Initialize(component) myControl = CType(component, MyMultiRgnControl) End Sub ' Make this control resizeable on the design surface Public Overrides ReadOnly Property AllowResize() As Boolean Get Return True End Get End Property ' Use the base to create child controls, then add region markers Protected Overrides Sub CreateChildControls() MyBase.CreateChildControls() ' Get a reference to the table, which is the first child control Dim t As Table t = CType(myControl.Controls(0), Table) ' Add design time markers for each of the three regions If Not IsNothing(t) Then ' View1 t.Rows(0).Cells(0).Attributes(DesignerRegion.DesignerRegionAttributeName) = "0" ' View2 t.Rows(0).Cells(1).Attributes(DesignerRegion.DesignerRegionAttributeName) = "1" ' Editable region t.Rows(1).Cells(0).Attributes(DesignerRegion.DesignerRegionAttributeName) = "2" End If End Sub ' Handler for the Click event, which provides the region in the arguments. Protected Overrides Sub OnClick(ByVal e As DesignerRegionMouseEventArgs) If IsNothing(e.Region) Then Return End If ' If the clicked region is not a header, return If e.Region.Name.IndexOf("Header") <> 0 Then Return End If ' Switch the current view if required If e.Region.Name.Substring(6, 1) <> myControl.CurrentView.ToString() Then myControl.CurrentView = Integer.Parse(e.Region.Name.Substring(6, 1)) MyBase.UpdateDesignTimeHtml() End If End Sub ' Create the regions and design-time markup. Called by the designer host. Public Overrides Function GetDesignTimeHtml(ByVal regions As DesignerRegionCollection) As String ' Create 3 regions: 2 clickable headers and an editable row regions.Add(New DesignerRegion(Me, "Header0")) regions.Add(New DesignerRegion(Me, "Header1")) ' Create an editable region and add it to the regions Dim editableRegion As EditableDesignerRegion = _ New EditableDesignerRegion(Me, _ "Content" & myControl.CurrentView, False) regions.Add(editableRegion) ' Set the highlight for the selected region regions(myControl.CurrentView).Highlight = True ' Use the base class to render the markup Return MyBase.GetDesignTimeHtml() End Function ' Get the content string for the selected region. Called by the designer host? Public Overrides Function GetEditableDesignerRegionContent(ByVal region As EditableDesignerRegion) As String ' Get a reference to the designer host Dim host As IDesignerHost = CType(Component.Site.GetService(GetType(IDesignerHost)), IDesignerHost) If Not IsNothing(host) Then Dim template As ITemplate = myControl.View1 If region.Name = "Content1" Then template = myControl.View2 End If ' Persist the template in the design host If Not IsNothing(template) Then Return ControlPersister.PersistTemplate(template, host) End If End If Return String.Empty End Function ' Create a template from the content string and put it ' in the selected view. Called by the designer host? Public Overrides Sub SetEditableDesignerRegionContent(ByVal region As EditableDesignerRegion, ByVal content As String) If IsNothing(content) Then Return End If ' Get a reference to the designer host Dim host As IDesignerHost = CType(Component.Site.GetService(GetType(IDesignerHost)), IDesignerHost) If Not IsNothing(host) Then ' Create a template from the content string Dim template As ITemplate = ControlParser.ParseTemplate(host, content) If Not IsNothing(template) Then ' Determine which region should get the template If region.Name.EndsWith("0") Then myControl.View1 = template ElseIf region.Name.EndsWith("1") Then myControl.View2 = template End If End If End If End Sub 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 Samples.ASPNet.ControlDesigners_CS { [ Designer(typeof(MyMultiRegionControlDesigner)), ToolboxData("<{0}:MyMultiRegionControl runat=\"server\" width=\"200\"></{0}:MyMultiRegionControl>") ] public class MyMultiRegionControl : CompositeControl { // Define the templates that represent 2 views on the control private ITemplate _view1; private ITemplate _view2; // Create persistable inner properties // for the two editable views [PersistenceMode(PersistenceMode.InnerProperty), DefaultValue(null)] public virtual ITemplate View1 { get { return _view1; } set { _view1 = value; } } [PersistenceMode(PersistenceMode.InnerProperty), DefaultValue(null)] public virtual ITemplate View2 { get { return _view2; } set { _view2 = value; } } // The current view on the control; 0 = view1, 1 = view2 private int _currentView = 0; public int CurrentView { get { return _currentView; } set { _currentView = value; } } // Create a simple table with a row of two clickable, // readonly headers and a row with a single column, which // is the 'container' to which we'll be adding controls. protected override void CreateChildControls() { // Always start with a clean form Controls.Clear(); // Create a table using the control's declarative properties Table t = new Table(); t.CellSpacing = 1; t.BorderStyle = BorderStyle; t.Width = this.Width; t.Height = this.Height; // Create the header row TableRow tr = new TableRow(); tr.HorizontalAlign = HorizontalAlign.Center; tr.BackColor = Color.LightBlue; // Create the first cell in the header row TableCell tc = new TableCell(); tc.Text = "View1"; tc.Width = new Unit("50%"); tr.Cells.Add(tc); // Create the second cell in the header row tc = new TableCell(); tc.Text = "View 2"; tc.Width = new Unit("50%"); tr.Cells.Add(tc); t.Rows.Add(tr); // Create the second row for content tr = new TableRow(); tr.HorizontalAlign = HorizontalAlign.Center; // This cell represents our content 'container' tc = new TableCell(); tc.ColumnSpan = 2; tr.Cells.Add(tc); t.Rows.Add(tr); // Add the finished table to the Controls collection Controls.Add(t); } } //--------------------------------------------------------- // Region-based control designer for the above web control, // derived from CompositeControlDesigner. public class MyMultiRegionControlDesigner : CompositeControlDesigner { private MyMultiRegionControl myControl; public override void Initialize(IComponent component) { base.Initialize(component); myControl = (MyMultiRegionControl)component; } // Make this control resizeable on the design surface public override bool AllowResize { get { return true; } } // Use the base to create child controls, then add region markers protected override void CreateChildControls() { base.CreateChildControls(); // Get a reference to the table, which is the first child control Table t = (Table)myControl.Controls[0]; // Add design time markers for each of the three regions if (t != null) { // View1 t.Rows[0].Cells[0].Attributes[DesignerRegion.DesignerRegionAttributeName] = "0"; // View2 t.Rows[0].Cells[1].Attributes[DesignerRegion.DesignerRegionAttributeName] = "1"; // Editable region t.Rows[1].Cells[0].Attributes[DesignerRegion.DesignerRegionAttributeName] = "2"; } } // Handler for the Click event, which provides the region in the arguments. protected override void OnClick(DesignerRegionMouseEventArgs e) { if (e.Region == null) return; // If the clicked region is not a header, return if (e.Region.Name.IndexOf("Header") != 0) return; // Switch the current view if required if (e.Region.Name.Substring(6, 1) != myControl.CurrentView.ToString()) { myControl.CurrentView = int.Parse(e.Region.Name.Substring(6, 1)); base.UpdateDesignTimeHtml(); } } // Create the regions and design-time markup. Called by the designer host. public override String GetDesignTimeHtml(DesignerRegionCollection regions) { // Create 3 regions: 2 clickable headers and an editable row regions.Add(new DesignerRegion(this, "Header0")); regions.Add(new DesignerRegion(this, "Header1")); // Create an editable region and add it to the regions EditableDesignerRegion editableRegion = new EditableDesignerRegion(this, "Content" + myControl.CurrentView, false); regions.Add(editableRegion); // Set the highlight for the selected region regions[myControl.CurrentView].Highlight = true; // Use the base class to render the markup return base.GetDesignTimeHtml(); } // Get the content string for the selected region. Called by the designer host? public override string GetEditableDesignerRegionContent(EditableDesignerRegion region) { // Get a reference to the designer host IDesignerHost host = (IDesignerHost)Component.Site.GetService(typeof(IDesignerHost)); if (host != null) { ITemplate template = myControl.View1; if (region.Name == "Content1") template = myControl.View2; // Persist the template in the design host if (template != null) return ControlPersister.PersistTemplate(template, host); } return String.Empty; } // Create a template from the content string and // put it in the selected view. public override void SetEditableDesignerRegionContent(EditableDesignerRegion region, string content) { if (content == null) return; // Get a reference to the designer host IDesignerHost host = (IDesignerHost)Component.Site.GetService(typeof(IDesignerHost)); if (host != null) { // Create a template from the content string ITemplate template = ControlParser.ParseTemplate(host, content); if (template != null) { // Determine which region should get the template // Either 'Content0' or 'Content1' if (region.Name.EndsWith("0")) myControl.View1 = template; else if (region.Name.EndsWith("1")) myControl.View2 = template; } } } } }

System.Web.UI.Design.DesignerObject
System.Web.UI.Design.DesignerRegion
System.Web.UI.Design.EditableDesignerRegion
System.Web.UI.Design.TemplatedEditableDesignerRegion
System.Web.UI.Design.WebControls.WizardStepEditableRegion


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


EditableDesignerRegion コンストラクタ (ControlDesigner, String)
アセンブリ: System.Design (system.design.dll 内)

Dim owner As ControlDesigner Dim name As String Dim instance As New EditableDesignerRegion(owner, name)


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


EditableDesignerRegion コンストラクタ

名前 | 説明 |
---|---|
EditableDesignerRegion (ControlDesigner, String) | 所有者と名前を指定して、EditableDesignerRegion クラスの新しいインスタンスを初期化します。 |
EditableDesignerRegion (ControlDesigner, String, Boolean) | 指定した所有者、名前、および ServerControlsOnly プロパティの初期値を使用して、EditableDesignerRegion クラスの新しいインスタンスを作成します。 |

EditableDesignerRegion コンストラクタ (ControlDesigner, String, Boolean)
アセンブリ: System.Design (system.design.dll 内)

Dim owner As ControlDesigner Dim name As String Dim serverControlsOnly As Boolean Dim instance As New EditableDesignerRegion(owner, name, serverControlsOnly)
public function EditableDesignerRegion ( owner : ControlDesigner, name : String, serverControlsOnly : boolean )


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


EditableDesignerRegion プロパティ

名前 | 説明 | |
---|---|---|
![]() | Content | 領域のコンテンツの HTML マークアップを取得または設定します。 |
![]() | Description | デザイナ領域の説明を取得または設定します。 ( DesignerRegion から継承されます。) |
![]() | Designer | 関連付けられたデザイナ コンポーネントを取得します。 ( DesignerObject から継承されます。) |
![]() | DisplayName | デザイナ領域の表示名を取得または設定します。 ( DesignerRegion から継承されます。) |
![]() | EnsureSize | デザイン ホストで領域サイズをデザイナ領域に明示的に設定するかどうかを示す値を取得または設定します。 ( DesignerRegion から継承されます。) |
![]() | Highlight | デザイン サーフェイス上でデザイナ領域を強調表示するかどうかを示す値を取得または設定します。 ( DesignerRegion から継承されます。) |
![]() | Name | オブジェクトの名前を取得します。 ( DesignerObject から継承されます。) |
![]() | Properties | オブジェクトのプロパティを取得します。 ( DesignerObject から継承されます。) |
![]() | Selectable | デザイン サーフェイス上でユーザーがデザイナ領域を選択できるかどうかを示す値を取得または設定します。 ( DesignerRegion から継承されます。) |
![]() | Selected | デザイン サーフェイス上でデザイナ領域が現在選択されているかどうかを示す値を取得または設定します。 ( DesignerRegion から継承されます。) |
![]() | ServerControlsOnly | 領域で受け入れることができるのが Web サーバー コントロールのみかどうかを示す値を取得または設定します。 |
![]() | SupportsDataBinding | 領域をデータ ソースにバインドできるかどうかを示す値を取得または設定します。 |
![]() | UserData | デザイナ領域に関連付けるオプションのユーザー データを取得または設定します。 ( DesignerRegion から継承されます。) |

EditableDesignerRegion メソッド

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | GetBounds | デザイン サーフェイス上のデザイナ領域のサイズを取得します。 ( DesignerRegion から継承されます。) |
![]() | GetChildViewRendering | 指定したコントロールのデザイン時 HTML マークアップを格納している ViewRendering オブジェクトを返します。 |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | GetService | 指定した型で識別されるサービスをデザイン ホストから取得します。 ( DesignerObject から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

EditableDesignerRegion メンバ
関連するコントロールのためのデザイン時マークアップ内の編集可能なコンテンツ領域を定義します。
EditableDesignerRegion データ型で公開されるメンバを以下の表に示します。


名前 | 説明 | |
---|---|---|
![]() | Content | 領域のコンテンツの HTML マークアップを取得または設定します。 |
![]() | Description | デザイナ領域の説明を取得または設定します。(DesignerRegion から継承されます。) |
![]() | Designer | 関連付けられたデザイナ コンポーネントを取得します。(DesignerObject から継承されます。) |
![]() | DisplayName | デザイナ領域の表示名を取得または設定します。(DesignerRegion から継承されます。) |
![]() | EnsureSize | デザイン ホストで領域サイズをデザイナ領域に明示的に設定するかどうかを示す値を取得または設定します。(DesignerRegion から継承されます。) |
![]() | Highlight | デザイン サーフェイス上でデザイナ領域を強調表示するかどうかを示す値を取得または設定します。(DesignerRegion から継承されます。) |
![]() | Name | オブジェクトの名前を取得します。(DesignerObject から継承されます。) |
![]() | Properties | オブジェクトのプロパティを取得します。(DesignerObject から継承されます。) |
![]() | Selectable | デザイン サーフェイス上でユーザーがデザイナ領域を選択できるかどうかを示す値を取得または設定します。(DesignerRegion から継承されます。) |
![]() | Selected | デザイン サーフェイス上でデザイナ領域が現在選択されているかどうかを示す値を取得または設定します。(DesignerRegion から継承されます。) |
![]() | ServerControlsOnly | 領域で受け入れることができるのが Web サーバー コントロールのみかどうかを示す値を取得または設定します。 |
![]() | SupportsDataBinding | 領域をデータ ソースにバインドできるかどうかを示す値を取得または設定します。 |
![]() | UserData | デザイナ領域に関連付けるオプションのユーザー データを取得または設定します。(DesignerRegion から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GetBounds | デザイン サーフェイス上のデザイナ領域のサイズを取得します。 (DesignerRegion から継承されます。) |
![]() | GetChildViewRendering | 指定したコントロールのデザイン時 HTML マークアップを格納している ViewRendering オブジェクトを返します。 |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | GetService | 指定した型で識別されるサービスをデザイン ホストから取得します。 (DesignerObject から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

Weblioに収録されているすべての辞書からEditableDesignerRegionを検索する場合は、下記のリンクをクリックしてください。

- EditableDesignerRegionのページへのリンク